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;
    
    }
    

      

  • 相关阅读:
    MYSQL学习笔记
    javascript30--day01--Drum kit
    jQuery--dataTable 前端分页与后端分页 及遇到的问题
    hexo博客
    js—数组那些事儿
    累死青蛙系列——青蛙跳台阶问题
    js—求数组中的最大最小值
    前端html,css考点
    doxygen 使用 教程 不含安装仅设置
    fatal error LNK1169: one or more multiply defined symbols found 终极解决方案
  • 原文地址:https://www.cnblogs.com/DF-yimeng/p/9615718.html
Copyright © 2011-2022 走看看