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. JSOI 2016 扭动的字符串

    JSOI 2016 扭动的字符串 题面描述 给出两个长度为\(n\)的字符串\(A,B\) \(S(i,j,k)\)表示把\(A\)中的\([i,j]\)和\(B\)中的\([j,k]\)拼接起来的字 ...

  2. Django项目:CRM(客户关系管理系统)--73--63PerfectCRM实现CRM讲师下载作业

    # teacher_urls.py # ————————62PerfectCRM实现CRM讲师讲课记录———————— from django.conf.urls import url from bp ...

  3. C++标准输入问题

    1.读取数据量不定的输入数据 e.g. #include <iostream> using namespace std; void main() { ,val=; while(cin> ...

  4. vue项目 环境搭建

    1.前端安装 安装项目:vue init webpack docvote 进入docvote里:cd docvote 安装脚手架:cnpm i 运行:npm run dev 2.异步加载 const ...

  5. pixhawk 常见问题 持续更新

    红灯蓝灯闪,初始化中,请稍等 黄灯双闪,错误,系统拒绝解锁 黄灯闪,遥控器关闭 黄灯快速闪且滴滴响,电池保护激活 蓝灯... 未见过.... 绿灯闪: 已加锁,GPS锁定已获得. 准备解锁. 从加锁状 ...

  6. NOSQL数据库之 REDIS

    NOSQL数据库之 REDIS 一.NOSQL 1.简介 NoSQL ,(Not Only SQL),泛指非关系型数据库. 特点: NoSQL 通常是以key-value形式存储, 不支持SQL语句, ...

  7. SSM-6nginx Linux下的安装

    1.下载nginx: 官方网站: http://nginx.org/download/ 2. 要求的安装环境 yum install gcc-c++ yum -y install pcre-devel ...

  8. JNI初级:android studio生成so文件详细过程

    本文主要参考blog:http://blog.csdn.net/jkan2001/article/details/54316375 下面是本人结合blog生成so包过程中遇到一些问题和解决方法 (1) ...

  9. linux定时跑php脚本,防止重复跑,死循环

    $PHP_SELF = realpath($_SERVER['PHP_SELF']); if (!($argc > 1)) { $lock_file = $PHP_SELF . '.lock'; ...

  10. 通过java打开jar 文件

    JAR文件是许多信息经过封装后形成的捆绑体.也就是一个压缩文件. JAR 文件格式提供了许多优势和功能,其中很多是传统的压缩格式如ZIP或者RAR所没有提供的,JAR文件 还用于安排和封装库.组件和插 ...