A. Appleman and easy tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard ou Tput
Toastman came up and a very easy task. He gives it to Appleman, but Appleman doesn ' t know what to solve it. Can you help him?
Given a n x n Checkerboard. Each cell of the board has either character 'X ', or character 'o '. Is it true this each cell of the board have even number of adjacent cells with 'o '? Both 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
English is really poor ah, no way, did not understand, learn English well, this semester over CET4, refueling!
It's too soon to go through this problem.
1#include <cstdio>2#include <cstring>3#include <iostream>4#include <algorithm>5 6 using namespacestd;7 Const intMax_size = the;8 9 intD1[] = {-1,0,0,1};Ten intD2[] = {0, -1,1,0}; One A BOOLCheckintXintYintN) - { - if(x >=0&& y >=0&& x < n && y <N) the return true; - return false; - } - + intMain () - { + intN; A intGraph[max_size][max_size]; at - while(SCANF ("%d%*c", &n)! =EOF) - { - for(inti =0; I < n; i++) - { - for(intj =0; J < N; J + +) in { - CharA =GetChar (); to if(A = ='o') +GRAPH[I][J] =1; - Else theGRAPH[I][J] =0; * } $ GetChar ();Panax Notoginseng } - the intTag =false; + for(inti =0; I < n; i++) A { the for(intj =0; J < N; J + +) + { - intAns =0; $ intx, y; $ for(intK =0; K <4; K + +) - { -x = i +D1[k]; they = j +D2[k]; - if(check (x, y, n))Wuyi { the if(Graph[x][y] = =1) -ans++; Wu } - } About if(Ans%2!=0) $ { -printf"no\n"); -Tag =true; - Break; A } + } the if(Tag = =true) - Break; $ } the if(Tag = =false) theprintf"yes\n"); the } the return 0; -}View Code
CodeForces462 A. Appleman and Easy Task