A. Appleman and Easy Task
time limit per test 

1 second

memory limit per test 

256 megabytes

input 

standard input

output 

standard output

Toastman 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
3
xxo
xox
oxx
output
YES
input
4
xxxo
xoxo
oxox
xxxx
output
NO

解题:暴力枚举即可。
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#define LL long long
#define pii pair<int,int>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = ;
int n;
char mp[maxn][maxn];
const int dir[][] = {,-,,,-,,,};
int main() {
int ans;
bool flag;
while(~scanf("%d",&n)){
getchar();
memset(mp,'x',sizeof(mp));
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++)
mp[i][j] = getchar();
getchar();
}
flag = true;
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
ans = ;
for(int k = ; k < ; k++){
int x = i+dir[k][];
int y = j+dir[k][];
if(mp[x][y] == 'o') ans++;
}
if(ans&) {flag = false;break;}
}
}
flag?puts("YES"):puts("NO");
}
return ;
}

最新文章

  1. SignalR实现网页实时聊天功能
  2. C++基本语法
  3. Servlet基础-手工编写第一个servlet
  4. 如何理解 Java 中的 &lt;T extends Comparable&lt;? super T&gt;&gt;
  5. CCF 201612-2 火车购票 (暴力)
  6. Generate List and Table via ng-repeat
  7. 由CAST()函数在.NET1.1和.NET4.0下处理机制不同所引发的BUG
  8. Kafka学习记录
  9. LeetCode 152
  10. Sleep的问题
  11. GTW likes math(BC 1001)
  12. linux通过文件查找依赖关系
  13. C++重载运算符的规则
  14. Cell.reuseIdentifier 指什么
  15. delphi 利用 InterlockedCompareExchange 实现主线程维一锁等待
  16. Django项目目录介绍
  17. day1-接口测试_jmeter_postman
  18. Qt画笔实现折线图
  19. Perl语言入门
  20. A Magic Lamp -- hdu -- 3183

热门文章

  1. SVN报错 Not Found In Revision 不支持空目录
  2. git merge合并时遇上refusing to merge unrelated histories的解决方案
  3. loadrunner11 安装破解,汉化包
  4. [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
  5. Using 10053 Trace Events and get outline
  6. Linux用户、用户组权限管理详解
  7. 专题七:UDP编程补充——UDP广播程序的实现
  8. js实现点击上下按钮,图片向上向下循环滚动切换
  9. WEB-CSS实现单行(多行)文本溢出显示省略号
  10. Dojo - 操作Dom的函数