Codeforces Round #827 (Div. 4) C. Stripes

On an 8×88×8 grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the cells through which it passes.

Determine which color was used last.

The red stripe was painted after the blue one, so the answer is R.

Input

The first line of the input contains a single integer tt (1≤t≤40001≤t≤4000) — the number of test cases. The description of test cases follows. There is an empty line before each test case.

Each test case consists of 88 lines, each containing 88 characters. Each of these characters is either 'R', 'B', or '.', denoting a red square, a blue square, and an unpainted square, respectively.

It is guaranteed that the given field is obtained from a colorless one by drawing horizontal red rows and vertical blue columns.

At least one stripe is painted.

Output

For each test case, output 'R' if a red stripe was painted last, and 'B' if a blue stripe was painted last (without quotes).

 

Note

The first test case is pictured in the statement.

In the second test case, the first blue column is painted first, then the first and last red rows, and finally the last blue column. Since a blue stripe is painted last, the answer is B.

思路 如果任意一行的R数量为8那么就代表最后是R 否则B

#include<bits/stdc++.h>
using namespace std;
#define max 8
int main()
{

   int n;
   cin>>n;

   int redcount;
   int count;
   while(n--){
       char s[10][10];
       redcount=0;
       
       for (int i = 0; i < max; i++)
           for (int j = 0; j < max; j++) {
               cin >> s[i][j];
           }
       for (int i = 0; i < max; i++) {
           count = 0;
           for (int j = 0; j < max; j++){
               if(s[i][j]=='R')
                   count++;
           }
           if(count==8)
               redcount=1;
       }
       if(redcount)
           cout<<"R"<<endl;
           else cout<<"B"<<endl;
   }
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值