称号:

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.

Sample test(s)
input
3
xxo
xox
oxx
output
YES
input
4
xxxo
xoxo
oxox
xxxx
output
NO

题意分析:

推断每一个位置相邻位置为o的数字,假设全为偶数就yes,否者no。简单模拟题。

Orz


代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream> using namespace std; char a[105][105];
int main()
{
int n;
char c;
int flag;
cin >> n;
memset(a, 0, sizeof(a));
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
{
cin >> c;
if (c == 'o')
a[i][j] = 1;
}
flag = 1; for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
{
int cnt = 0;
if (a[i-1][j])
++cnt;
if (a[i+1][j])
++cnt;
if (a[i][j-1])
++cnt;
if (a[i][j+1])
++cnt;
if (cnt & 1)
{
flag = false;
break;
}
}
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl; return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

Codeforces Round #263 (Div. 2) proA的更多相关文章

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

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

  2. Codeforces Round #263 (Div. 2)

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

  3. Codeforces Round #263 (Div. 1)

    B 树形dp 组合的思想. Z队长的思路. dp[i][1]表示以i为跟结点的子树向上贡献1个的方案,dp[i][0]表示以i为跟结点的子树向上贡献0个的方案. 如果当前为叶子节点,dp[i][0] ...

  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) D. Appleman and Tree(树形DP)

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

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

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

  7. 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 ...

  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)C(贪心,联想到huffman算法)

    数学家伯利亚在<怎样解题>里说过的解题步骤第二步就是迅速想到与该题有关的原型题.(积累的重要性!) 对于这道题,可以发现其实和huffman算法的思想很相似(可能出题人就是照着改编的).当 ...

随机推荐

  1. Android Wear之android穿戴式设备应用开发平台

    Android Wear于2014年03月19日公布,并有Moto 360和LG watch两款产品. 眼下源代码还没有开放.可是开发人员能够下载它的Image及相应的开发SDK,这样开发人员通过模拟 ...

  2. IIS服务器能支持10万并发

    服务器能支持10万并发由于一个项目的访问量越来越大,从原来的几百个,增加到现在50多万个每天,所以阿里的服务器也扛不住了,于是就想办法,查了N多资料,总结了以下方法,才解决这问题,每天一共访问量50多 ...

  3. TF-IDF模型

    TF-IDF模型 1. 理论基础 由于数据挖掘所有数据都要以数字形式存在,而文本是以字符串形式存在.所以进行文本挖掘时需要先对字符串进行数字化,从而能够进行计算.TF-IDF就是这样一种技术,能够将字 ...

  4. 【t010】最近距离

    Time Limit: 1 second Memory Limit: 32 MB [问题描述] 聚类方法要求将空间中的点集,按照一点的方式进行归类,要求每一类中的点集相互之间的距离足够的"近 ...

  5. USB 3.0规范中译本 第6章 物理层

    本文为CoryXie原创译文,转载及有任何问题请联系cory.xie#gmail.com. 6.1 物理层概览 物理层定义超高速总线的信号技术.本章定义超高速物理层的电气要求. 本节定义超高速组件之间 ...

  6. [TypeScript] Simplify asynchronous callback functions using async/await

    Learn how to write a promise based delay function and then use it in async await to see how much it ...

  7. BZOJ1415 聪聪与可可 - 期望dp

    传送门 题目大意: 一张无向图上有一只猫和一只老鼠,猫先走,鼠后走.猫每次会向与其相邻的并且距离老鼠最近的点移动(若距离相等去编号较小的),如果移动一步后还没吃到老鼠,还可以再移动一步(算在一个时间内 ...

  8. 在向server发送请求时发生传输级错误。 (provider: 共享内存提供程序, error: 0 - 管道的还有一端上无不论什么进程。

    作者:卿笃军 原文地址:http://blog.csdn.net/qingdujun/article/details/36425825 SQL Server 2008 + VS2010 用C#编写的代 ...

  9. 使用ant编译项目技能

    ant编译时指定jdk的版本号 系统的jdk版本号是1.6,而项目使用的jdk版本号是1.5.所以在编译时须要指定jdk的版本号为1.5,能够使用以下的方法为javac 任务指定fork和execut ...

  10. RabbitMQ 延迟队列实现订单支付结果异步阶梯性通知

    在第三方支付中,例如支付宝.或者微信,对于订单请求,第三方支付系统采用的是消息同步返回.异步通知+主动补偿查询的补偿机制. 由于互联网通信的不可靠性,例如双方网络.服务器.应用等因素的影响,不管是同步 ...