Codeforces 259A Little Elephant and Chess

Source: Internet
Author: User

Little Elephant and ChessTime limit:2000MS Memory Limit:262144KB 64bit IO Format:%i64d &%i6 4u SubmitStatusPracticecodeforces 259A

Description

The Little Elephant loves chess very much.

One day the Little Elephant and he friend decided to play chess. They ' ve got the chess pieces but the board is a problem. They ' ve got An 8x8 checkered board, each square was painted either black or white. The Little Elephant and his friend know that A proper chessboarddoesn ' t has any side -adjacent cells with the same color and the upper left cell are white. To play chess, they want to make the board they has a proper chessboard. For this friends can choose any row of the board and cyclically shift the cells of the chosen row, which is, put the LA St (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 in all).

For example, if the first line of the board looks like that ' BBBBBBWW ' (the white cells of the line ismarked with CH Aracter "W", the black cells is marked with character "B"), and after one cyclic shift it would look like that " C3>wbbbbbbw ".

Help the Little Elephant and he friend to find out whether they can use any number of the described operations to turn th E board they has into a proper chessboard.

Input

The input consists of exactly eight lines. 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 ' B Oard. Character "W" stands for the white color, Character 'B ' stands for the black color.

Consider the rows of the board numbered from 1 through 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

Input
Wbwbwbwb
Bwbwbwbw
Bwbwbwbw
Bwbwbwbw
Wbwbwbwb
Wbwbwbwb
Bwbwbwbw
Wbwbwbwb
Output
YES
Input
Wbwbwbwb
Wbwbwbwb
Bbwbwwwb
Bwbwbwbw
Bwbwbwbw
Bwbwbwww
Bwbwbwbw
Bwbwbwbw
Output
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, you can achieve the goal.

1#include <stdio.h>2#include <string.h>3 intMain ()4 {5     inti,j;6     Chara[Ten][Ten];7      while(SCANF ("%s", a[1])!=EOF)8     {9          for(i=2; i<=8; i++)Tenscanf"%s", A[i]); One         //For (i=1;i<=8;i++) A             //printf ("%s\n", A[i]); -         intflg=1; -          for(i=1; i<=8; i++) the         { -             if(a[i][0]==a[i][7]) -             { -                 //printf ("1%d\n", i); +flg=0; -                  Break; +             } A              for(j=1; j<=7; j + +) at             { -                 if(a[i][j]==a[i][j-1]) -                 { -                     //printf ("2%d%d\n", i,j); -flg=0; -                      Break; in                 } -             } to             if(flg==0) +                  Break; -         } the         if(flg==1) *printf"yes\n"); $         ElsePanax Notoginsengprintf"no\n"); -     } the     return 0; +}
View Code

Codeforces 259A Little Elephant and Chess

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.