ZCMU新人训练赛-B
Tom's Meadow
Tom has a meadow in his garden. He divides it into N * M squares. Initially all the squares were covered with grass. He mowed down the grass on some of the squares and thinks the meadow is beautiful if and only if
- Not all squares are covered with grass.
- No two mowed squares are adjacent.
Two squares are adjacent if they share an edge. Here comes the problem: Is Tom's meadow beautiful now?
Input
The input contains multiple test cases!
Each test case starts with a line containing two integers N, M (1 <= N, M <= 10) separated by a space. There follows the description of Tom's Meadow. There're Nlines each consisting of M integers separated by a space. 0(zero) means the corresponding position of the meadow is mowed and 1(one) means the square is covered by grass.
A line with N = 0 and M = 0 signals the end of the input, which should not be processed
<b< dd="">
Output
One line for each test case.
Output "Yes" (without quotations) if the meadow is beautiful, otherwise "No"(without quotations).
<b< dd="">
Sample Input
2 2
1 0
0 1
2 2
1 1
0 0
2 3
1 1 1
1 1 1
0 0
<b< dd="">
Sample Output
Yes
No
No
#include <iostream>
using namespace std;
bool arr[][];
int main()
{
int n,m;
while(cin>>n>>m&&n!=)
{
bool flag=true;
int sum=;
for(int i=;i<n;i++)
{ for(int j=;j<m;j++)
{
cin>>arr[i][j];
sum+=arr[i][j];
if((arr[i][j]==&&j>&&arr[i][j-]==)||(i>&&arr[i-][j]==&&arr[i][j]==))
{
flag=false; }
}
} if(flag&&sum!=m*n)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl; }
return ;
}
ZCMU新人训练赛-B的更多相关文章
- 10.0.0.55_12-16训练赛部分writeup
0x1 - MISC MISC100 一张帅行的照片 目测是图片隐写,但是binwalk并没有出来,应该是对文件头进行了修改 010editor查看一下,发现在jpg文件尾之后还有大量的数据 而且在灰 ...
- Contest1592 - 2018-2019赛季多校联合新生训练赛第二场(部分题解)
Contest1592 - 2018-2019赛季多校联合新生训练赛第二场 D 10248 修建高楼(模拟优化) H 10252 组装玩具(贪心+二分) D 传送门 题干 题目描述 C 市有一条东西走 ...
- Contest1585 - 2018-2019赛季多校联合新生训练赛第一场(部分题解)
Contest1585 - 2018-2019赛季多校联合新生训练赛第一场 C 10187 查找特定的合数 D 10188 传话游戏 H 10192 扫雷游戏 C 传送门 题干: 题目描述 自然数中除 ...
- 7.30 正睿暑期集训营 A班训练赛
目录 2018.7.30 正睿暑期集训营 A班训练赛 T1 A.蔡老板分果子(Hash) T2 B.蔡老板送外卖(并查集 最小生成树) T3 C.蔡老板学数学(DP NTT) 考试代码 T2 T3 2 ...
- HDU6578 2019HDU多校训练赛第一场 1001 (dp)
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...
- HDU6579 2019HDU多校训练赛第一场1002 (线性基)
HDU6579 2019HDU多校训练赛第一场1002 (线性基) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6579 题意: 两种操作 1.在序列末 ...
- ZCMU训练赛-J(循环节+字符串处理)
J - Java Beans There are N little kids sitting in a circle, each of them are carrying some java bean ...
- ZCMU训练赛-H(模拟)
H - Hard to Play MightyHorse is playing a music game called osu!. After playing for several months ...
- ZCMU训练赛-B(dp/暴力)
B - Break Standard Weight The balance was the first mass measuring instrument invented. In its tradi ...
随机推荐
- JS判断页面是否加载完成
用 document.readyState == "complete" 判断页面是否加载完成 传回XML 文件资料的目前状况. 基本语法intState = xmlDocument ...
- JS容易理解错误的地方
在这端代码执行的末尾,你会不会hi变量回事函数中的hi了?你会不会认为这不是按引用传递了? 对值传递和引用传递产生质疑了? 1 var hi = {}; 2 function sayHello(hi) ...
- requestAnimationFrame实现一帧的函数节流
用一个变量判断raf的回调是否已经执行了,已经执行了说明过了一帧,通常是16.7ms,达到了函数节流一帧的目的. var locked = false; window.addEventListense ...
- 停课day2
感觉今天好颓啊,我才把昨晚那五道题a了,(但我明明一直在学啊,为啥这么慢,难道是我太笨了?) 闲话少叙,先说做法 问题 A: C Looooops 题目描述 对于C的for(i=A ; i!=B ;i ...
- 【BZOJ4325】NOIP2015 斗地主 搜索+贪心
这个东西考试的时候一眼以为状压就压炸了考试又了一下午.....最后我打出来发现后几个点10min都过不去,我大概算了一下,可能是吧.......最后一脸懵逼的我去怂了正解,我们发现只要确定了顺子就可以 ...
- WCF分布式开发步步为赢(12):WCF事务机制(Transaction)和分布式事务编程
今天我们继续学习WCF分布式开发步步为赢系列的12节:WCF事务机制(Transaction)和分布式事务编程.众所周知,应用系统开发过程中,事务是一个重要的概念.它是保证数据与服务可靠性的重要机制. ...
- [uva 1350]数位dp+二分
题目链接:https://vjudge.net/problem/38405 #include<bits/stdc++.h> using namespace std; ][]; ]; lon ...
- Cannot read property 'resetFields' of undefined 问题及引申
问题描述: 使用element开发我的后台系统,编辑和新增使用了同一个弹出框<el-dialog><el-form></el-form></el-dialog ...
- java web标签
一:国庆结束了,回来上班,结果老大说过两天才出差,所以这两天就用来补自己不太懂的知识或者以前没有熟悉的知识,jsp的标签就是,因为在项目中自己封装了一些标签,但是我自己只是会用,真正的原理性的东西我还 ...
- HDU2544最短路---(Dijkstra)
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...