Appleman and Easy Task-cf
来源:互联网 发布:逆战神枪手源码 编辑:程序博客网 时间:2024/05/17 07:01
A. Appleman and Easy Task
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputToastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?
Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the board are adjacent if they share a side.
Input
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
Output
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
Sample test(s)
input
3xxoxoxoxx
output
YES
input
4xxxoxoxooxoxxxxx
output
NO
#include<iostream>using namespace std;char a[200][200];int vis[200][200];int n;int dfs(int i, int j){int num = 0;if (a[i - 1][j] == 'o'&&i>0 && i <= n&&j <= n&&j>0)num++;if (a[i][j - 1] == 'o'&&i>0 && i <= n&&j <= n&&j>0)num++;if (a[i][j + 1] == 'o'&&i>0 && i <= n&&j <= n&&j>0)num++;if (a[i + 1][j] == 'o'&&i>0 && i <= n&&j <= n&&j>0)num++;return num;}int main(){//int n;cin >> n;for (int i = 1; i <= n; i++){for (int j = 1; j <= n; j++){cin >> a[i][j];}}int x = 0, flag = 0;for (int i = 1; i <= n; i++){for (int j = 1; j <= n; j++){x = dfs(i, j);if (x % 2 != 0){flag = 1;break;}}if (flag)break;}if (flag)cout << "NO" << endl;elsecout << "YES" << endl;}
0 0
- Appleman and Easy Task-cf
- Appleman and Easy Task
- A. Appleman and Easy Task
- A. Appleman and Easy Task 8-26
- 462A - Appleman and Easy Task
- 【CODEFORCES】 A. Appleman and Easy Task
- codeforces 462A Appleman and Easy Task
- Codeforces Round #263 (Div. 2)A. Appleman and Easy Task
- Codeforces Round #263 (Div. 2)A. Appleman and Easy Task
- Codeforces Round #263 (div2) A. Appleman and Easy Task
- Codeforces 462A Appleman and Easy Task(水题)
- A. Appleman and Easy Task( brute force implementation)
- CF 461D Appleman and Complicated Task解题报告
- Codeforces Round #263 (Div. 2) A.Appleman and Easy Task(坑)
- CF 462B Appleman and Card Game
- CF 461 A Appleman and Toastman
- CF 263div2 C. Appleman and Toastman
- 【Codeforces Round 263 (Div 2)A】【水题 认真读题】Appleman and Easy Task 每个点的相邻o是否都为偶数
- 实现业务系统中的用户权限管理--设计篇
- 【燕十八PHP学习笔记-2】运算
- 页面禁止鼠标滑动全选
- UIView动画学习笔记
- java使用JNA调用系统Kernel32.dll文件示例
- Appleman and Easy Task-cf
- 黑马程序员------Category:分类
- NAL与I帧判别
- 碳硫仪
- 2048 游戏中自动生成卡片实现
- MIME协议(二) -- MIME .
- java 实现快速排序
- UE ctags生成配置
- AXIS创建wsdl文件盒生成客户端和服务器端