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.

Examples
input
3
xxo
xox
oxx
output
YES
input
4
xxxo
xoxo
oxox
xxxx
output
NO

【题意】:Two cells of the board are adjacent if they share a side. 指的是四周

【Code】:
#include <bits/stdc++.h>
using namespace std;
const int N =110;
int cnt,n; char a[N][N];
int dir[][2]={ {-1,0},{0,-1},{1,0},{0,1} }; int dfs(int x,int y)
{
for(int i=0;i<4;i++)
{
int dx=x+dir[i][0];
int dy=y+dir[i][1]; if(dx>=0&&dy>=0&&dx<n&&dy<n)
{
if(a[dx][dy]=='o')
cnt++;
}
}
return cnt;
}
bool check()
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(dfs(i,j)&1)
return false;
}
}
return true;
}
int main()
{
cin>>n;
for(int i=0;i<n;i++)
scanf("%s",a[i]); printf("%s\n",check()?"YES":"NO");
return 0;
}

  

Codeforces Round #263 (Div. 2) A. Appleman and Easy Task【地图型搜索/判断一个点四周‘o’的个数的奇偶】的更多相关文章

  1. 贪心 Codeforces Round #263 (Div. 2) C. Appleman and Toastman

    题目传送门 /* 贪心:每次把一个丢掉,选择最小的.累加求和,重复n-1次 */ /************************************************ Author :R ...

  2. Codeforces Round #263 (Div. 2) D. Appleman and Tree(树形DP)

    题目链接 D. Appleman and Tree time limit per test :2 seconds memory limit per test: 256 megabytes input ...

  3. Codeforces Round #263 (Div. 1) C. Appleman and a Sheet of Paper 树状数组暴力更新

    C. Appleman and a Sheet of Paper   Appleman has a very big sheet of paper. This sheet has a form of ...

  4. Codeforces Round #263 Div.1 B Appleman and Tree --树形DP【转】

    题意:给了一棵树以及每个节点的颜色,1代表黑,0代表白,求将这棵树拆成k棵树,使得每棵树恰好有一个黑色节点的方法数 解法:树形DP问题.定义: dp[u][0]表示以u为根的子树对父亲的贡献为0 dp ...

  5. Codeforces Round #263 (Div. 2) A B C

    题目链接 A. Appleman and Easy Task time limit per test:2 secondsmemory limit per test:256 megabytesinput ...

  6. Codeforces Round #263 (Div. 2) proA

    称号: A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input ...

  7. Codeforces Round #263 (Div. 2)

    吐槽:一辈子要在DIV 2混了. A,B,C都是简单题,看AC人数就知道了. A:如果我们定义数组为N*N的话就不用考虑边界了 #include<iostream> #include &l ...

  8. Codeforces Round #263 (Div. 2) proC

    题目: C. Appleman and Toastman time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. Codeforces Round #263 (Div. 2) proB

    题目: B. Appleman and Card Game time limit per test 1 second memory limit per test 256 megabytes input ...

随机推荐

  1. C#计算两个时间的时间差,精确到年月日时分秒

    喏,计算两个时间的时间差,精确到年月日时分秒 看起来比较笨的方法了,不知道有没有改进 DateTime d1 = new DateTime(2016, 4, 1, 0, 0, 0); DateTime ...

  2. C#Image和Icon的相互转化

    Image img = Image.FromHbitmap(icon.ToBitmap().GetHbitmap()); Graphics g = Graphics.FromImage(img); g ...

  3. redis Hash 命令

    HDEL key field2 [field2] 删除一个或多个哈希表字段 HEXISTS key field 查看哈希表 key 中,指定的字段是否存在. HGET key field 获取存储在哈 ...

  4. [Cqoi2015] 编号 【逆向思维,暴力枚举】

    Online Judge:Luogu-P4222 Label:逆向思维,暴力枚举 题目描述 你需要给一批商品编号,其中每个编号都是一个7位16进制数(由0~9, a-f组成).为了防止在人工处理时不小 ...

  5. Leetcode139. Word Break单词拆分

    给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词. 说明: 拆分时可以重复使用字典中的单词. 你可以假设字典中没有重复 ...

  6. day65作业

    有 红.黄.蓝 三个按钮,以及一个200x200矩形框box,点击不同的按钮,box的颜色会被切换为指定的颜色 <body> <div id="app"> ...

  7. Location protocol 属性

    Location protocol 属性 定义和用法 protocol 属性是一个可读可写的字符串,可设置或返回当前 URL 的协议. 语法 location.protocol <!DOCTYP ...

  8. 【vue】/vue-ele-project

    作者大大的地址是:https://github.com/JinwenXie/vue-ele-project 还是老办法,先运行项目看看效果 我不算是外卖爱好者,不过觉得那个添加商品到购物车的动画效果很 ...

  9. bzoj 1034 [ZJOI2008]泡泡堂BNB——贪心

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1034 原来觉得和 bzoj4977跳伞求生 有点像(虽然还没做). 所以对于a[ ]从小到大 ...

  10. TZ_12_Spring的RestTemplate

    1.Http客户端工具 HttpClient:HttpClient是Apache公司的产品,是Http Components下的一个组件. 特点: 基于标准.纯净的Java语言.实现了Http1.0和 ...