#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<string> s(N);
for (auto &v : s) {
cin >> v;
}
int ans = 0;
for (int m = 0; m < min(N, M); m++) {
for (int i = m; i < N; i++) {
int j = m;
if (s[i][j] == 'W') {
if (i >= 2 && s[i - 1][j] == 'G' && s[i - 2][j] == 'R') {
ans++;
s[i][j] = s[i - 1][j] = s[i - 2][j] = '*';
}
if (j >= 2 && s[i][j - 1] == 'G' && s[i][j - 2] == 'R') {
ans++;
s[i][j] = s[i][j - 1] = s[i][j - 2] = '*';
}
}
}
for (int j = m; j < M; j++) {
int i = m;
if (s[i][j] == 'W') {
if (i >= 2 && s[i - 1][j] == 'G' && s[i - 2][j] == 'R') {
ans++;
s[i][j] = s[i - 1][j] = s[i - 2][j] = '*';
}
if (j >= 2 && s[i][j - 1] == 'G' && s[i][j - 2] == 'R') {
ans++;
s[i][j] = s[i][j - 1] = s[i][j - 2] = '*';
}
}
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |