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. 封装了一个HOOKAPI的类。。。

    我惊奇地发现,我手竟然这么生了.....   很久很久没有写这方面的东西,现在写着竟然这么手生....哎....   这玩艺,还得天天练....

  2. Leetcode944. Delete Columns to Make Sorted删列造序

    给定由 N 个小写字母字符串组成的数组 A,其中每个字符串长度相等. 选取一个删除索引序列,对于 A 中的每个字符串,删除对应每个索引处的字符. 所余下的字符串行从上往下读形成列. 比如,有 A = ...

  3. git 命令行(一)-版本回退

    1. 版本回退 在实际工作中,我们脑子里怎么可能记得一个几千行的文件每次都改了什么内容,不然要版本控制系统干什么.版本控制系统肯定有某个命令可以告诉我们历史记录,在Git中,我们用 git log 命 ...

  4. MyBatis配置文件(九)--mappers映射器

    映射器是MyBatis中最复杂.最核心的组件,本文先介绍映射器的引入方法,其他的在我日后会再做分析和总结. 之前的文章中有提到过,映射器是由一个接口和一个XML配置文件组成,XML文件中需要定义一个命 ...

  5. JDK、Eclipse、Tomcat、Maven、IDEA 常见问题

    windows操作分成了32位和64位的系统,不同的系统安装的软件也不一样. 查询电脑操作系统是多少位? J D K 01. 下载安装 02. 目录解释 03. 配置环境变量 (JDK安装成功后进行配 ...

  6. Redis学习笔记02-消息队列与延时队列

    写在前面:Redis的消息队列并不是专业的消息队列,没有ACK保证,没有特别多的高级特性,如果对消息的可靠性有很高的要求,就放弃它吧. 1.Redis消息队列 Redis通过内部的list数据结构来实 ...

  7. 浓缩版 《C和指针》基础篇(Chpt.1~Chpt.9)

    导语 近日,笔者在课业之余阅读了<C和指针(Pointers on C)> (by Kenneth A.Reek)一书,从中记录了关于C语言的诸多知识点,包括在C语言基础特性的学习过程中没 ...

  8. TZOJ 4021 Ugly Problem(线段树区间子段最大)

    描述 给定一个序列A[0],A[1],…A[N-1],要求找到p0,p1,p2,p3使得A[p0]+A[p0+1]+…+A[p1] + A[p2]+A[p2+1]+…+A[p3]最大(0<=p0 ...

  9. LA2238 Fixed Partition Memory Management

    题目大意: m(m<=10)个内存区域,n(n<=50)个程序.找出一个方案来,使得平均结束时刻尽量小.题目保证有解. 同一个程序运行在不同大小的内存区域内,其运行时间不同.(注意,这里说 ...

  10. Veristand学习札记(3)- CD的开发

    转载:https://blog.csdn.net/mfcjishiben/article/details/79417739 1 CustomDevice开发 CD的开发必须遵照NI提供的模板进行.安装 ...