[ 9.9 ]CF每日一题系列—— 259A黑白棋盘检查问题

时间:2021-06-01 13:59:05

http://codeforces.com/problemset/problem/259/A

PS9.8日做了但是忘了发博客,所以坚持3天了呦~

终于读懂了这个题了,心累

Describe:
  给你8 * 8的棋盘摆放问题,行的顺序可能是错乱的,问给你的8行是否能组成棋盘

Solution:
  所以我们要检查的就是

  1.棋盘有没有相邻的颜色相同

  2.开头必须得是4 白 + 4黑(嘿嘿嘿,一开始我就是这么想的,但是!!!题目中右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).)表示我们可以随意选择行,然后循环移动之,所以第二个条件必定满足,所以我们只需要判断第一个条件是否满足就好~

/*
http://codeforces.com/problemset/problem/259/A
终于读懂了
*/
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
const int maxn = 10;
char s[maxn][maxn];
int main()
{
int n = 8,flag = 1;
for(int i = 0;i < n;++i)
{
scanf("%s",&s[i]);
}
for(int i = 0;i < n && flag;++i)
{
for(int j = 0;j < n - 1 && flag;++j)
{
if(s[i][j] == s[i][j + 1])flag = 0;
}
}
if(flag)printf("YES\n");
else printf("NO\n");
return 0; }