Codeforces 263A. Appleman and Easy Task

Source: Internet
Author: User

A. Appleman and Easy TaskTime limit per test 1 secondmemory limit per test megabytes input Standard Input Output Standard Output

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

Problem solving: Brute force enumeration.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <climits>7#include <vector>8#include <queue>9#include <cstdlib>Ten#include <string> One#include <Set> A#include <stack> - #defineLL Long Long - #definePII pair<int,int> the #defineINF 0x3f3f3f3f - using namespacestd; - Const intMAXN = the; - intN; + CharMP[MAXN][MAXN]; - Const intdir[4][2] = {0,-1,0,1,-1,0,1,0}; + intMain () { A     intans; at     BOOLFlag; -      while(~SCANF ("%d",&N)) { - GetChar (); -Memset (MP,'x',sizeof(MP)); -          for(inti =1; I <= N; i++){ -              for(intj =1; J <= N; J + +) inMP[I][J] =GetChar (); - GetChar (); to         } +Flag =true; -          for(inti =1; I <= N; i++){ the              for(intj =1; J <= N; J + +){ *Ans =0; $                  for(intK =0; K <4; k++){Panax Notoginseng                     intx = i+dir[k][0]; -                     inty = j+dir[k][1]; the                     if(Mp[x][y] = ='o') ans++; +                 } A                 if(ans&1) {flag =false; Break;} the             } +         } -Flag?puts ("YES"):p UTS ("NO"); $     } $     return 0; -}
View Code

Codeforces 263A. 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.