Codeforces 263A. Appleman and Easy Task
2024-10-21 03:27:43
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 ;
}
最新文章
- SignalR实现网页实时聊天功能
- C++基本语法
- Servlet基础-手工编写第一个servlet
- 如何理解 Java 中的 <;T extends Comparable<;? super T>;>;
- CCF 201612-2	火车购票 (暴力)
- Generate List and Table via ng-repeat
- 由CAST()函数在.NET1.1和.NET4.0下处理机制不同所引发的BUG
- Kafka学习记录
- LeetCode 152
- Sleep的问题
- GTW likes math(BC 1001)
- linux通过文件查找依赖关系
- C++重载运算符的规则
- Cell.reuseIdentifier 指什么
- delphi 利用 InterlockedCompareExchange 实现主线程维一锁等待
- Django项目目录介绍
- day1-接口测试_jmeter_postman
- Qt画笔实现折线图
- Perl语言入门
- A Magic Lamp -- hdu -- 3183
热门文章
- SVN报错 Not Found In Revision 不支持空目录
- git merge合并时遇上refusing to merge unrelated histories的解决方案
- loadrunner11 安装破解,汉化包
- [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
- Using 10053 Trace Events and get outline
- Linux用户、用户组权限管理详解
- 专题七:UDP编程补充——UDP广播程序的实现
- js实现点击上下按钮,图片向上向下循环滚动切换
- WEB-CSS实现单行(多行)文本溢出显示省略号
- Dojo - 操作Dom的函数