zoukankan      html  css  js  c++  java
  • [ 9.9 ]CF每日一题系列—— 259A黑白棋盘检查问题

    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
    ");
        else printf("NO
    ");
        return 0;
    
    }
    

      

  • 相关阅读:
    shell的一本书
    linux设置网络三种方法
    BIOS讲解
    对于ssh和hadoop联系讲解和ssh的基本内容
    Httphandler
    ASP.NET配置文件
    Httpmoudle
    ASP.NET页面生命周期
    ASP.NET页面跳转方法的集合
    OutputCache的使用
  • 原文地址:https://www.cnblogs.com/DF-yimeng/p/9615718.html
Copyright © 2011-2022 走看看