Codeforces 263A. Appleman and Easy Task

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

3xxoxoxoxx

output

YES

input

4xxxoxoxooxoxxxxx

output

NO

解题:暴力枚举即可。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <climits>
 7 #include <vector>
 8 #include <queue>
 9 #include <cstdlib>
10 #include <string>
11 #include <set>
12 #include <stack>
13 #define LL long long
14 #define pii pair<int,int>
15 #define INF 0x3f3f3f3f
16 using namespace std;
17 const int maxn = 110;
18 int n;
19 char mp[maxn][maxn];
20 const int dir[4][2] = {0,-1,0,1,-1,0,1,0};
21 int main() {
22     int ans;
23     bool flag;
24     while(~scanf("%d",&n)){
25         getchar();
26         memset(mp,‘x‘,sizeof(mp));
27         for(int i = 1; i <= n; i++){
28             for(int j = 1; j <= n; j++)
29                 mp[i][j] = getchar();
30             getchar();
31         }
32         flag = true;
33         for(int i = 1; i <= n; i++){
34             for(int j = 1; j <= n; j++){
35                 ans = 0;
36                 for(int k = 0; k < 4; k++){
37                     int x = i+dir[k][0];
38                     int y = j+dir[k][1];
39                     if(mp[x][y] == ‘o‘) ans++;
40                 }
41                 if(ans&1) {flag = false;break;}
42             }
43         }
44         flag?puts("YES"):puts("NO");
45     }
46     return 0;
47 }

时间: 2024-10-09 19:35:20

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

CodeForces462 A. Appleman and Easy Task

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

哈理工2015暑假训练赛BNU16488 Easy Task(简单题)

A - Easy Task Time Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu SubmitStatusPracticeZOJ 2969 Description Calculating the derivation of a polynomial is an easy task. Given a function f(x) , we use (f(x))' to denote its derivatio

Codeforces 583 DIV2 Robot&#39;s Task 贪心

原题链接:http://codeforces.com/problemset/problem/583/B 题意: 就..要打开一个电脑,必须至少先打开其他若干电脑,每次转向有个花费,让你设计一个序列,使得总花费最小. 题解: 就傻傻的走就好..从左走到右,再走回来,更新序列和答案就好. 代码: #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #define MA

HDU-1076-An Easy Task(Debian下水题测试.....)

An Easy Task Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17062    Accepted Submission(s): 10902 Problem Description Ignatius was born in a leap year, so he want to know when he could hold h

[ACM] ZOJ 3844 Easy Task (模拟+哈希)

Easy Task Time Limit: 2 Seconds      Memory Limit: 65536 KB You are given n integers. Your task is very easy. You should find the maximum integer a and the minimum integer b among these n integers. And then you should replace both a and bwith a-b. Yo

Codeforces 467E Alex and Complicated Task(高效)

题目链接:Codeforces 467E Alex and Complicated Task 题目大意:给定一个长度为n序列,然后从中挑选尽量多的4元组(不能重叠). 解题思路:每次找的四元组的左端肯定是要尽量小的.所以用一个单调栈维护,如果新加入的数x在栈中出现过,那么就将两个数之间的数标记为在x.如果一个数的标记不为空,就意味着找到对应的四元组.有因为序列是从左遍历过去的,所以找到的一定是最优的. #include <cstdio> #include <cstring> #in

杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> /* 题意:找闰年. if((i%4==0 && i%100!=0) || i%400==0)count++; 3 2005 25 1855 12 2004 10000 2108 1904 43236 */ int main() { int t,y,n; int i,count=0; whil

ZOJ 2969: Easy Task

ZOJ 2969: Easy Task 1 ///@date 2017-02-07 2 ///@author Sycamore, ZJNU 3 #include <iostream> 4 using namespace std; 5 int c[1001]; 6 int main() 7 { 8 int T; 9 cin >> T; 10 while (T--) 11 { 12 int N; 13 cin >> N; 14 for (int i = N; i >=

HDU-------An Easy Task

An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4088 Accepted Submission(s): 2327   Problem Description Ignatius was born in a leap year, so he want to know when he could hold his bir