#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<char>> d(n, vector<char>(m));
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> d[i][j];
vector<vector<bool>> b(n, vector<bool>(m, false));
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (d[i][j] == 'R') {
if (j + 2 < m && d[i][j + 1] == 'G' && d[i][j + 2] == 'W') {
if (!b[i][j] && !b[i][j + 1] && !b[i][j + 2]) {
cnt++;
b[i][j] = b[i][j + 1] = b[i][j + 2] = true;
}
}
if (i + 2 < n && d[i + 1][j] == 'G' && d[i + 2][j] == 'W') {
if (!b[i][j] && !b[i + 1][j] && !b[i + 2][j]) {
cnt++;
b[i][j] = b[i + 1][j] = b[i + 2][j] = true;
}
}
}
}
}
cout << cnt;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |