A. Appleman and Easy Task 8-26
来源:互联网 发布:重庆大学网络教学平台 编辑:程序博客网 时间:2024/06/07 00:37
我刚才写了一篇,然后点击保存后就消失了。。。 吐槽一下
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). Thenn lines follow containing the description of the checkerboard. Each of them containsn characters (either 'x' or 'o') without spaces.
Output
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
Input
3xxoxoxoxx
Output
YES
Input
4xxxoxoxooxoxxxxx
Output
NO题意:给一个 n*n 的矩阵,每个点由 x 或者 o 构成。 如果每个点它周围的点中o 的个数为偶数,就是true。
思路:题意理解了,就是扫描一遍。
注意:关键是理解题,昨天别人读的题把我坑惨了。也怪自己英语不好!!六级没过呀!!!明天都要记单词!!!
#include<iostream>#include<cstdio>using namespace std;int main (){char a[102][102];int tx[4]={-1,0,1,0};int ty[4]={0,-1,0,1};int n,i,j,k,qs,bj;int x,y;while(cin>>n){bj=0;qs=0;for(i=0;i<n;i++)for(j=0;j<n;j++)cin>>a[i][j];for(i=0;i<n;i++)for(j=0;j<n;j++){for(k=0;k<4;k++){x=i+tx[k];y=j+ty[k];if(x<0||y<0||x>=n||y>=n)continue;else if(a[x][y]=='o')qs++;else;}if(qs%2==1){bj=1;}}if(bj==1)cout<<"NO"<<endl;elsecout<<"YES"<<endl;}return 0;}
0 0
- A. Appleman and Easy Task 8-26
- A. Appleman and Easy Task
- 462A - Appleman and Easy Task
- 【CODEFORCES】 A. Appleman and Easy Task
- codeforces 462A Appleman and Easy Task
- Appleman and Easy Task
- Appleman and Easy Task-cf
- Codeforces Round #263 (Div. 2)A. Appleman and Easy Task
- Codeforces Round #263 (Div. 2)A. Appleman and Easy Task
- Codeforces Round #263 (div2) A. Appleman and Easy Task
- Codeforces 462A Appleman and Easy Task(水题)
- A. Appleman and Easy Task( brute force implementation)
- Codeforces Round #263 (Div. 2) A.Appleman and Easy Task(坑)
- 【Codeforces Round 263 (Div 2)A】【水题 认真读题】Appleman and Easy Task 每个点的相邻o是否都为偶数
- A. Appleman and Toastman
- 461A - Appleman and Toastman
- Codeforces-461A Appleman and Toastman
- Appleman and Toastman - CodeForces 461 A 水题
- wpf自定义按钮样式
- 帮助文档(*.chm)制作 以及在winform程序中的应用
- HDU 3635-Dragon Balls(高级并查集)
- 兼容各大浏览器的js 数组删除元素方法方法
- Spring连接MySQL、Oracle和SQL Server的数据库运动连接属性
- A. Appleman and Easy Task 8-26
- Tchart的横纵坐标最大和最小值如何用语句设置Tchart的横纵坐标最大和最小值
- 遍历Map四种
- Hibernate4实战之注解版
- 【再曝猛料】 Virglass手机影院系列产品即将诞生
- 从面试题中学算法(2)---求数组中唯一n个出现1次的数字(n=1,2,3)
- Android ViewPager+Fragment,标示跟着ViewPager的滑动而同时滑动
- 每天一个linux命令:Linux 目录结构
- J2EE应用的五种核心策略以及实现