ZOJ 2850 Beautiful Meadow
2016-02-19 20:17
375 查看
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2850
#include<iostream> #include<cstdio> #include<string> #include<string.h> #include<cmath> #include<algorithm> using namespace std; int graph[20][20]; int main() { int n, m; while (cin >> n >> m) { if (n == 0 && m == 0)break; int cot0 = 0, cot1 = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &graph[i][j]); if (graph[i][j] == 1)cot1++; else cot0++; } } if (cot0 == 0) { printf("No\n"); continue; } int flag = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (graph[i][j] == 0) { if (i - 1 >= 0) { if (graph[i - 1][j] == 0) { flag = 0; goto there; } } if (i + 1 <n) { if (graph[i + 1][j] == 0) { flag = 0; goto there; } } if (j - 1 >= 0) { if (graph[i ][j-1] == 0) { flag = 0; goto there; } } if (j +1 < m) { if (graph[i ][j+1] == 0) { flag = 0; goto there; } } } } } there: if (flag == 0)printf("No\n"); else printf("Yes\n"); } return 0; }
相关文章推荐
- java核心技术学习笔记(一)
- 针对Android 模拟器启动慢的问题
- MyISAM与InnoDB区别
- Mac平台中编译安装Lua运行环境及Hello Lua实例
- Theano 学习笔记 Basics:Baby Steps - Algebra
- ZOJ 2849 Attack of Panda Virus
- Calculator
- leetcode:Rotate List
- Linux 源码安装Python
- 新手必备的常用代码片段整理(一)
- [Locked] Number of Connected Components in an Undirected Graph
- jsp 界面注册、登录按钮的实现
- IOS 文件系统
- 安卓 自动弹出键盘
- hrbust 1176 小陈老师、雪人【map+优先队列】
- 部署Apache网站服务
- 安卓 单例设计模式 查看方法
- HDU 4602 Partition
- CTeX终于要更新了
- BadUSB的防范研究