Codeforces 263A. 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 解题:暴力枚举即可。
#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的更多相关文章
- 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 ...
- 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 ...
- Codeforces 461D. Appleman and Complicated Task 构造,计数
原文链接https://www.cnblogs.com/zhouzhendong/p/CF461D.html 题解 首先我们可以发现如果确定了第一行,那么方案就唯一了. 然后,我们来看看一个点的值确定 ...
- Codeforces Gym 100002 D"Decoding Task" 数学
Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com ...
- An Easy Task
An Easy Task Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- Codeforces 461B Appleman and Tree(木dp)
题目链接:Codeforces 461B Appleman and Tree 题目大意:一棵树,以0节点为根节点,给定每一个节点的父亲节点,以及每一个点的颜色(0表示白色,1表示黑色),切断这棵树的k ...
- 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 ...
随机推荐
- 2008提权之突破系统权限安装shift后门
大家都知道08权限的系统权限设置很严格,且在2003系统中常用到的溢出工具都失效.面对限制IP连接的情况 我们及时拿到system权限 有账号也上不去 这种情况下只能弄shift后门 或者放大镜了.但 ...
- PCB 2019年IT工作主题【降本增效】 词云
降本增效是IT部门永恒的主题,从自身做起.踏踏实实把工作做好 在线词云制作软件: https://wordart.com/create
- 0627-TP整理三(对表的操作,数据的显示)
一.对表的操作 直接sql语句:(query/execute) 1.查询: 查询所有:M('表名')->select(); 查询一条数据:M('表名')->find(); 条件查询: 动态 ...
- bzoj 4031: [HEOI2015]小Z的房间【矩阵树定理】
是板子题,因为mod不是质数所以需要辗转相除然而并不知道为啥 高斯消元部分还不知道原理呢--先无脑背过的 #include<iostream> #include<cstdio> ...
- noip2002矩阵覆盖(搜索)
矩阵覆盖 题目描述 在平面上有 n 个点(n <= 50),每个点用一对整数坐标表示.例如:当 n=4 时,4个点的坐标分另为:p1(1,1),p2(2,2),p3(3,6),P4(0,7),见 ...
- INT类型知多少
前言: 整型是MySQL中最常用的字段类型之一,通常用于存储整数,其中int是整型中最常用的,对于int类型你是否真正了解呢?本文会带你熟悉int类型相关知识,也会介绍其他整型字段的使用. 1.整型分 ...
- [C++ STL] 迭代器(iterator)详解
背景:指针可以用来遍历存储空间连续的数据结构,但是对于存储空间非连续的,就需要寻找一个行为类似指针的类,来对非数组的数据结构进行遍历.因此,我们引入迭代器概念. 一.迭代器(iterator)介绍 ...
- [SHOI2013]超级跳马
题目描述 现有一个n 行m 列的棋盘,一只马欲从棋盘的左上角跳到右下角.每一步它向右跳奇数列,且跳到本行或相邻行.跳越期间,马不能离开棋盘.试求跳法种数mod 30011. 输入输出格式 输入格式: ...
- [TJOI2012]桥
Description 有n个岛屿,m座桥,每座桥连通两座岛屿,桥上会有一些敌人,玩家只有消灭了桥上的敌人才能通过,与此同时桥上的敌人会对玩家造成一定伤害.而且会有一个大Boss镇守一座桥,以玩家目前 ...
- Android 性能优化(9)网络优化( 5)Optimizing Server-Initiated Network Use
Optimizing Server-Initiated Network Use This lesson teaches you to Send Server Updates with GCM Netw ...