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 ...
随机推荐
- [CF912B]New Year's Eve
题意:在1~n中选不超过m个数,求其异或最大值 题解:经过找规律发现如果m为1,输出n,不然输出最小的不超过n的2^k-1 C++ Code: #include<cstdio> using ...
- [洛谷P2568]GCD
题目大意:给你$n(1\leqslant n\leqslant 10^7)$,求$\displaystyle\sum\limits_{x=1}^n\displaystyle\sum\limits_{y ...
- Brainf**k(一位数求max)
题目大意:给你两个一位数,要你求出其中的较大值(使用$Brainf**k$) ($Brainf**k$简介,相当于有一个数组和一个指针,","为把数组当前位赋值为读入的数,&quo ...
- 在iis上部署ssl证书 https
1.取走证书下载下来的文件.解压iis的压缩包. 2.打开internet信息服务iis管理器 3.双击打开后,选择导入,导入我们刚刚解压得到的pfx文件,这个pfx文件就是你需要部署域名的那个文件. ...
- maven pom继承与聚合
一.POM聚合模块: 在分布式架构,分模块化开发中,每个某块可能都是一个单独的maven项目,能够独立的进行项目构架,当模块比较多时,可以使用maven聚合聚合项目来简化maven构建,一次构建多个项 ...
- 使用google api material icons在网页中插入图标
在<head></head>中加入这一句: <link rel='stylesheet' href='http://fonts.googleapis.com/icon?f ...
- Educational Codeforces Round 54 (Rated for Div. 2) ABCD
A. Minimizing the String time limit per test 1 second memory limit per test 256 megabytes Descriptio ...
- P2765 魔术球问题(网络流24题)
题目描述 «问题描述: 假设有n根柱子,现要按下述规则在这n根柱子中依次放入编号为1,2,3,...的球. (1)每次只能在某根柱子的最上面放球. (2)在同一根柱子中,任何2个相邻球的编号之和为完全 ...
- JS模块化工具requirejs教程01
转自:http://www.runoob.com/w3cnote/requirejs-tutorial-1.html 随着网站功能逐渐丰富,网页中的js也变得越来越复杂和臃肿,原有通过script标签 ...
- Python 入门学习笔记
安装和运行 官网下载安装包https://www.python.org/downloads/mac-osx/下载完直接安装即可 运行打开 terminal,输入命令 python,进入 python ...