#include <bits/stdc++.h>
typedef enum{
RED,
GREEN,
WHITE
} colors;
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n, m;
std::cin >> n >> m;
colors r[n][m];
bool r_b[5][5] = {
{false,false,false,false},
{false,false,false,false},
{false,false,false,false},
{false,false,false,false}};
std::string k;
for(int i = 0; i < n; i++){
std::cin >> k;
for(int y = 0; y < m; y++){
switch(k[y]){
case 'R':
r[i][y] = RED;
break;
case 'G':
r[i][y] = GREEN;
break;
case 'W':
r[i][y] = WHITE;
break;
}
}
k.clear();
}
int count = 0;
for(int h = 0; h < m; h++){
for(int o = 0; o < n; o++){
if(r[o][h] == RED && o + 2 < n && r[o + 1][h] == GREEN && r[o + 2][h] == WHITE && r_b[o][h] == false && r_b[o + 1][h] == false && r_b[o + 2][h] == false) {
count++;
r_b[o][h] = true;
r_b[o + 1][h] = true;
r_b[o + 2][h] = true;
}
}
}
for(int h = 0; h < n; h++){
for(int o = 0; o < m; o++){
if(r[h][o] == RED && o + 2 < m && r[h][o + 1] == GREEN && r[h][o + 2] == WHITE && r_b[h][o] == false && r_b[h][o + 1] == false && r_b[h][o + 2] == false){
count++;
r_b[h][o] = true;
r_b[h][o + 1] = true;
r_b[h][o + 2] = true;
}
}
}
std::cout << count << '\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |