CodeForces462 A. Appleman and Easy Task
1 second
256 megabytes
standard input
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.
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.
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
3
xxo
xox
oxx
YES
4
xxxo
xoxo
oxox
xxxx
NO
英语真的是差啊,没办法,没理解,好好学英语,这学期过CET4,加油!
遍历搞一下这道题就过了。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std;
const int max_size = ; int d1[] = {-, , , };
int d2[] = {, -, , }; bool check(int x, int y, int n)
{
if(x >= && y >= && x < n && y < n)
return true;
return false;
} int main()
{
int n;
int graph[max_size][max_size]; while(scanf("%d%*c", &n) != EOF)
{
for(int i = ; i < n; i++)
{
for(int j = ; j < n; j++)
{
char a = getchar();
if(a == 'o')
graph[i][j] = ;
else
graph[i][j] = ;
}
getchar();
} int tag = false;
for(int i = ; i < n; i++)
{
for(int j = ; j < n; j++)
{
int ans = ;
int x, y;
for(int k = ; k < ; k ++)
{
x = i + d1[k];
y = j + d2[k];
if(check(x, y, n))
{
if(graph[x][y] == )
ans++;
}
}
if(ans % != )
{
printf("NO\n");
tag = true;
break;
}
}
if(tag == true)
break;
}
if(tag == false)
printf("YES\n");
}
return ;
}
CodeForces462 A. Appleman and Easy Task的更多相关文章
- Codeforces 263A. Appleman and Easy Task
A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input ...
- Codeforces Round #263 (Div. 2) A. Appleman and Easy Task【地图型搜索/判断一个点四周‘o’的个数的奇偶】
A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...
- An Easy Task
An Easy Task Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- HDU-------An Easy Task
An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- ZOJ 2969 Easy Task
E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...
- An Easy Task(简箪题)
B. An Easy Task Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO f ...
- HDU-1076-An Easy Task(Debian下水题測试.....)
An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- HD1046An Easy Task
Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birt ...
- HDOJ 1076 An Easy Task(闰年计算)
Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birt ...
随机推荐
- ajax 的返回值类型
ajax的dataType类型有三种:text,json,xml. text类型: 主页面: $.ajax({ url:"chuli.php", dataType:&quo ...
- 【转】Maven3把命令行创建的web工程转成Eclipse和IntelliJ Idea的工程
参考链接:http://blog.sina.com.cn/s/blog_4f925fc30102ed5b.html 大前提:在执行mvn eclipse:eclipse命令之前一定要先存在一个含有po ...
- 搭建FTP服务器
yum install vsftpd -yyum install pam* db4* --skip-broken –y 创建并生成vsftpd 数据库文件vi /etc/vsftpd/ftpusers ...
- codevs2800 送外卖
题目描述 Description 有一个送外卖的,他手上有n份订单,他要把n份东西,分别送达n个不同的客户的手上.n个不同的客户分别在1~n个编号的城市中.送外卖的从0号城市出发,然后n个城市都要走一 ...
- UI第九节——UIStepper
- (void)viewDidLoad { [super viewDidLoad]; // 实例化UIStepper,大小是固定的 UIStepper *stepper = ...
- PHP curl获取页面内容,不直接输出到页面,CURLOPT_RETURNTRANSFER参数设置
使用PHP curl获取页面内容或提交数据,有时候希望返回的内容作为变量储存,而不是直接输出.这个时候就必需设置curl的或true. 1.curl获取页面内容, 直接输出例子: <?php $ ...
- Linux常用系统管理命令(top、free、kill、df)
top -c #任务管理器 free -m #查看内存使用情况 kill -9 2312 (说明:强制杀死进程 kill -9 pid ) df -h #查看磁盘 ...
- Alpha版本十天冲刺——Day 5
站立式会议 会前小侃:今天是双11,也是恰逢组内秋鑫同学生日,本组同学祝他双11生日快乐.天气好冷,注意保暖. 会议总结 队员 今天完成 遇到的问题 明天要做 感想 鲍亮 json数据解析学习,完成注 ...
- jquery.validate.js插件使用
jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...
- poj 1192
此题亦一眼看出算法,一次AC. 没什么好讲的,就是一个普通的树形动规. 用dp[n][0]表示n号顶点不取时的最大值,dp[n][1]表示n号顶点取时的最大值. dp[n][0]=max{dp[x][ ...