『题解』Codeforces 1742C Stripes

Problem

\(8 \times 8\) 的网格上,轮流染上红色和蓝色。

  • 红色只能染一整行。
  • 蓝色只能染一整列。

问最后用的是哪种颜色。

Solution

题目说明了至少会染一个条纹,所以我们只需判断有没有一行是 RRRRRRRR 就行了。

因为没有 RRRRRRRR,那必定就是最后染的蓝色。

如果有当然就是最后染的红色啦。

Code

#include <bits/stdc++.h>
using namespace std;

#define file(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);
#define r(x) x = read()

inline int read()
{
    int d = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
        d = (d << 3) + (d << 1) + ch - 48, ch = getchar();
    return d;
}

string grid[10];

void work()
{
    bool flag = false;
    for (int i = 1; i <= 8; i ++)
    {
        cin >> grid[i];
        if (grid[i] == "RRRRRRRR")
            flag = true;
    }

    if (flag == true)
        cout << "R\n";
    else
        cout << "B\n";
}

int main()
{
    file("stripes");
    int tt = 1;
    r(tt);
    while (tt --)
        work();
    return 0;
}
posted @ 2022-11-26 21:33  Clyfort  阅读(159)  评论(0)    收藏  举报