fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef double dl;
  6.  
  7. #define endl "\n"
  8. #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  9. #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
  10.  
  11. int main()
  12. {
  13. optimize();
  14. int t,c=0,d=0, e=0,f=0;
  15. cin >> t;
  16. while(t--)
  17. {
  18. char s[8][8];
  19. for(int i=0;i<8;i++)
  20. {
  21. for(int j=0;j<8;j++)
  22. {
  23. cin >> s[i][j];
  24. if(s[i][j]=='B')
  25. c++;
  26. else
  27. break;
  28. }
  29. if(c==8)
  30. {
  31. cout << 'B' << endl;
  32. break;
  33. }
  34. else
  35. c=0;
  36. for(int j=0;j<8;j++)
  37. {
  38. if(s[i][j]=='R')
  39. d++;
  40. else
  41. break;
  42. }
  43. if(d==8)
  44. {
  45. cout << 'R' << endl;
  46. break;
  47. }
  48. else
  49. d=0;
  50.  
  51. for(int j=0;j<8;j++)
  52. {
  53. if(s[j][i]=='B')
  54. e++;
  55. else
  56. break;
  57. }
  58. if(e==8)
  59. {
  60. cout << 'B' << endl;
  61. break;
  62. }
  63. else
  64. e=0;
  65. for(int j=0;j<8;j++)
  66. {
  67. if(s[j][i]=='R')
  68. f++;
  69. else
  70. break;
  71. }
  72. if(f==8)
  73. {
  74. cout << 'R' << endl;
  75. break;
  76. }
  77. else
  78. f=0;
  79. }
  80. }
  81. return 0;
  82. }
  83.  
Success #stdin #stdout 0.01s 5288KB
stdin
4


....B...
....B...
....B...
RRRRRRRR
....B...
....B...
....B...
....B...


RRRRRRRB
B......B
B......B
B......B
B......B
B......B
B......B
RRRRRRRB


RRRRRRBB
.B.B..BB
RRRRRRBB
.B.B..BB
.B.B..BB
RRRRRRBB
.B.B..BB
.B.B..BB


........
........
........
RRRRRRRR
........
........
........
........
stdout
Standard output is empty