CF259A.Little Elephant and Chess

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 chessboard doesn'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 operation multiple 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.

小象非常喜欢国际象棋。

一天,小象和他的朋友决定下国际象棋。他们已经有了棋子,但棋盘却成了问题。他们有一块 8×88 \times 8 的方格棋盘,每个方格被涂成黑色或白色。小象和他的朋友知道:一个标准的国际象棋棋盘不能存在任意两个边相邻(即共享一条边)的同色方格,且左上角方格必须是白色。为了能下棋,他们希望将手头的棋盘变为一个标准棋盘。为此,他们可以任选棋盘的一行,并对该行进行循环右移操作:即将该行最右侧(最后一个)方格移到最左侧(第一个位置),其余方格均向右移动一格。该操作可执行任意多次(包括零次)。

例如,若棋盘第一行形如 "BBBBBBWW"(其中用字符 "W" 表示白色方格,"B" 表示黑色方格),则执行一次循环右移后,该行将变为 "WBBBBBBW"。

请帮助小象和他的朋友判断:能否通过执行任意次数的上述操作,将他们手中的棋盘变为一个标准棋盘?

输入格式

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.

输入恰好包含八行。每行恰好包含八个字符,每个字符为“W”或“B”,中间无空格:第 ii 行中的第 jj 个字符表示大象棋盘上第 ii 行第 jj 列格子的颜色。“W”表示白色,“B”表示黑色。

将棋盘的行从上到下编号为 11 至 88,列从左到右编号为 11 至 88。给定的棋盘初始时可能是一个合法的国际象棋棋盘。

输出格式

In a single line print "YES" (without the quotes), if we can make the board a proper chessboard and "NO" (without the quotes) otherwise.

如果可以将棋盘变为标准的国际象棋棋盘,则在一行中输出 "YES"(不带引号);否则输出 "NO"(不带引号)。

输入输出样例

  • 输入#1

    WBWBWBWB
    BWBWBWBW
    BWBWBWBW
    BWBWBWBW
    WBWBWBWB
    WBWBWBWB
    BWBWBWBW
    WBWBWBWB

    输出#1

    YES
  • 输入#2

    WBWBWBWB
    WBWBWBWB
    BBWBWWWB
    BWBWBWBW
    BWBWBWBW
    BWBWBWWW
    BWBWBWBW
    BWBWBWBW

    输出#2

    NO

说明/提示

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.

在第一个样例中,您应将以下行向右移动一个位置:第 3 行、第 6 行、第 7 行和第 8 行。

在第二个样例中,无法达成目标。

输入解题思路,AI测评打分。不知道怎么写?

首页