CodeForces462 A. Appleman and Easy Task

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.