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

解题:暴力枚举即可。
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#define LL long long
#define pii pair<int,int>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = ;
int n;
char mp[maxn][maxn];
const int dir[][] = {,-,,,-,,,};
int main() {
int ans;
bool flag;
while(~scanf("%d",&n)){
getchar();
memset(mp,'x',sizeof(mp));
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++)
mp[i][j] = getchar();
getchar();
}
flag = true;
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
ans = ;
for(int k = ; k < ; k++){
int x = i+dir[k][];
int y = j+dir[k][];
if(mp[x][y] == 'o') ans++;
}
if(ans&) {flag = false;break;}
}
}
flag?puts("YES"):puts("NO");
}
return ;
}

Codeforces 263A. Appleman and Easy Task的更多相关文章

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

  2. CodeForces462 A. Appleman and Easy Task

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

  3. Codeforces 461D. Appleman and Complicated Task 构造,计数

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF461D.html 题解 首先我们可以发现如果确定了第一行,那么方案就唯一了. 然后,我们来看看一个点的值确定 ...

  4. Codeforces Gym 100002 D"Decoding Task" 数学

    Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com ...

  5. An Easy Task

    An Easy Task Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total ...

  6. Codeforces 461B Appleman and Tree(木dp)

    题目链接:Codeforces 461B Appleman and Tree 题目大意:一棵树,以0节点为根节点,给定每一个节点的父亲节点,以及每一个点的颜色(0表示白色,1表示黑色),切断这棵树的k ...

  7. HDU-------An Easy Task

    An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  8. ZOJ 2969 Easy Task

    E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...

  9. An Easy Task(简箪题)

    B. An Easy Task Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO f ...

随机推荐

  1. linux centos7安装mysql

    1.下载并安装官方的 yum repository (新建了mysql文件夹) wget -i -c http://dev.mysql.com/get/mysql57-community-releas ...

  2. mysql插入二千万的测试数据进行测试,int和datetime比较

    时间存储用int和datetime哪个字段更合适,建立下面的两个表 测试环境是内存2个G,一核的虚拟机 CREATE TABLE `test_inttime` ( `id` int(11) NOT N ...

  3. n阶完全生成图的数量

    有些事不是看到了希望才去坚持,而是坚持了才会看到希望 问题 I: 星际之门(一) 时间限制: Sec 内存限制: MB 提交: 解决: [提交][状态][讨论版] 题目描述 公元3000年,子虚帝国统 ...

  4. Vue知识点小总结1

    ES6常用语法 变量的定义 let定义变量 不会变量提升 有全局作用域和函数作用域,块级作用域{} 不能重复定义 var定义变量 会变量提升 只有全局作用域和函数作用域 能够重复定义 const定义变 ...

  5. 【转】rpm包和源码包安装的区别

    转自:https://blog.csdn.net/junjie_6/article/details/59483785 建议在安装线上的生产服务器软件包时都用源码安装,这是因为源码安装可以自行调整编译参 ...

  6. Spark学习之RDD编程(2)

    Spark学习之RDD编程(2) 1. Spark中的RDD是一个不可变的分布式对象集合. 2. 在Spark中数据的操作不外乎创建RDD.转化已有的RDD以及调用RDD操作进行求值. 3. 创建RD ...

  7. python自动化--模块操作之re、MySQL、Excel

    一.python自有模块正则 import re # re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None print(re.match("www ...

  8. Spring框架之控制反转和依赖注入

    学Spring框架必须理解控制反转和依赖注入.下面各自举一个例子,来说明控制反转和依赖注入. IOC(控制反转):应用本身创建和维护的依赖对象:现在交由外部容器(Spring)来创建和维护:这个控制权 ...

  9. Hibernate框架之HQL查询与Criteria 查询的区别

    Hibernate框架提供了HQL查询和Criteria 查询.下面对这两种查询分别做个例子.也好对这两种查询方法有个大概的了解.就用房屋信息表做例子,查询所有房屋信息. HQL语句查询所有房屋信息: ...

  10. C++11:using 的各种作用

    C++11中using关键字的主要作用是:为一个模板库定义一个别名. 文章链接:派生类中使用using别名改变基类成员的访问权限  一.<Effective Modern C++>里有比较 ...