This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int n, m;
string g[1001];
int solve(int i, int j) {
int ret = 0;
while (i < n and j > -1) {
if (j + 2 < m and g[i][j] == 'R' and g[i][j + 1] == 'G' and g[i][j + 2] == 'W') {
ret++;
g[i][j] = g[i][j + 1] = g[i][j + 2] = '.';
}
}
while (i < n and j > -1) {
if (i + 2 < n and g[i][j] == 'R' and g[i + 1][j] == 'G' and g[i + 2][j] == 'W') {
ret++;
g[i][j] = g[i + 1][j] = g[i + 2][j] = '.';
}
}
return ret;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> g[i];
}
int ans = 0;
for (int i = 0; i < m; i++) {
ans += solve(0, i);
}
for (int i = 1; i < n; i++) {
ans += solve(i, m - 1);
}
cout << ans << '\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... |