CodeForces 259A Little Elephant and Chess
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
The Little Elephant loves chess very much.
One day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8 × 8 checkered board, each square is painted either black or white. The Little Elephant and his friend know that a proper chessboarddoesn't have any side-adjacent cells with the same color and the upper left cell is white. To play chess, they want to make the board they have a proper chessboard. For that the friends can choose any row of the board and cyclically shift the cells of the chosen row, that is, put the last (rightmost) square on the first place in the row and shift the others one position to the right. You can run the described operationmultiple times (or not run it at all).
For example, if the first line of the board looks like that "BBBBBBWW" (the white cells of the line are marked with character "W", the black cells are marked with character "B"), then after one cyclic shift it will look like that "WBBBBBBW".
Help the Little Elephant and his friend to find out whether they can use any number of the described operations to turn the board they have into a proper chessboard.
Input
The input consists of exactly eight lines. Each line contains exactly eight characters "W" or "B" without any spaces: the j-th character in the i-th line stands for the color of the j-th cell of the i-th row of the elephants' board. Character "W" stands for the white color, character "B" stands for the black color.
Consider the rows of the board numbered from 1 to 8 from top to bottom, and the columns — from 1 to 8 from left to right. The given board can initially be a proper chessboard.
Output
In a single line print "YES" (without the quotes), if we can make the board a proper chessboard and "NO" (without the quotes) otherwise.
Sample Input
WBWBWBWB
BWBWBWBW
BWBWBWBW
BWBWBWBW
WBWBWBWB
WBWBWBWB
BWBWBWBW
WBWBWBWB
YES
WBWBWBWB
WBWBWBWB
BBWBWWWB
BWBWBWBW
BWBWBWBW
BWBWBWWW
BWBWBWBW
BWBWBWBW
NO
Hint
In the first sample you should shift the following lines one position to the right: the 3-rd, the 6-th, the 7-th and the 8-th.
In the second sample there is no way you can achieve the goal.
#include <stdio.h>
#include <string.h>
int main()
{
int i,j;
char a[][];
while(scanf("%s",a[])!=EOF)
{
for(i=;i<=;i++)
scanf("%s",a[i]);
//for(i=1;i<=8;i++)
//printf("%s\n",a[i]);
int flg=;
for(i=;i<=;i++)
{
if(a[i][]==a[i][])
{
//printf("1 %d\n",i);
flg=;
break;
}
for(j=;j<=;j++)
{
if(a[i][j]==a[i][j-])
{
//printf("2 %d %d\n",i,j);
flg=;
break;
}
}
if(flg==)
break;
}
if(flg==)
printf("YES\n");
else
printf("NO\n");
}
return ;
}
CodeForces 259A Little Elephant and Chess的更多相关文章
- CodeForces - 204C Little Elephant and Furik and Rubik
CodeForces - 204C Little Elephant and Furik and Rubik 个人感觉是很好的一道题 这道题乍一看我们无从下手,那我们就先想想怎么打暴力 暴力还不简单?枚 ...
- Codeforces D. Little Elephant and Interval(思维找规律数位dp)
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...
- Codeforces Round #300 D. Weird Chess 水题
D. Weird Chess Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/proble ...
- CodeForces 221D Little Elephant and Array
Little Elephant and Array Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on C ...
- 【29.89%】【codeforces 734D】Anton and Chess
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 559C Gerald and Giant Chess
C. Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces 204A Little Elephant and Interval
http://codeforces.com/problemset/problem/204/A 题意:给定一个[L,R]区间,求这个区间里面首位和末尾相同的数字有多少个 思路:考虑这个问题满足区间加减, ...
- Codeforces 258D Little Elephant and Broken Sorting (看题解) 概率dp
Little Elephant and Broken Sorting 怎么感觉这个状态好难想到啊.. dp[ i ][ j ]表示第 i 个数字比第 j 个数字大的概率.转移好像比较显然. #incl ...
- Codeforces 258C Little Elephant and LCM
Little Elephant and LCM #include<bits/stdc++.h> #define LL long long #define fi first #define ...
随机推荐
- 机器学习(Machine Learning)&深入学习(Deep Learning)资料
<Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost 到随机森林. ...
- emulator-arm.exe 已停止工作、 emulator-x86 已停止工作
问题描述: emulator-arm.exe 已停止工作. emulator-x86 已停止工作.AVD模拟器启动一直黑屏.AVD模拟器启动一直显示andorid界面 解决方法: 1. sdk的安 ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON TestObjDef
zw版[转发·台湾nvp系列Delphi例程]HALCON TestObjDef procedure TForm1.Button1Click(Sender: TObject);var img : HU ...
- 转:Eclipse常用开发插件
以下是我整理的自己开发过程中的常用Eclipse插件,按字母排序: (1) AmaterasUML 介绍:Eclipse的UML插件,支持UML活动图,class图,sequen ...
- sql基础查询
2.1 指定使用中的资料库 一个资料库伺服器可以建立许多需要的资料库,所以在你执行任何资料库的操作前,通常要先指定使用的资料库.下列是指定资料库的指令: 如果你使用「MySQL Workbench」这 ...
- 161020、web调试工具fiddler介绍及使用
简介: Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的"进出"Fiddler的数据(指cookie,ht ...
- React笔记_(7)_react路由
路由 路由(routing)是指分组从源到目的地时,决定端到端路径的网络范围的进程. 路由器当然是作为一个转发设备出现的,主要是转发数据包来实现网络互联. 那么react的路由到底指的是什么呢? 举个 ...
- android 在应用中切换语言
场景: 在设置中切换中英文,然后跳转MainActivity....步骤: 1.在MyApplication 中初始化语言 public class MyApplication extends App ...
- MySQL 添加列,修改列,删除列
ALTER TABLE:添加,修改,删除表的列,约束等表的定义. 查看列:desc 表名; 修改表名:alter table t_book rename to bbb; 添加列:alter table ...
- OC基础数据类型-NSData
1.NSData,数据,当我们需要把一些信息写入到文件里或发送到网络上,我们需要把这些数据转换下,变成纯粹的0.1字符流 1 NSString * str = @"hello, world! ...