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 <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;
vector<pair<int, int>> order;
for (int m = 0; m < N + M; m++) {
for (int i = m; i >= 0; i--) {
int j = m - i;
if (i >= N || j >= M) {
continue;
}
order.emplace_back(i, j);
}
}
for (auto [i, j] : order) {
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 |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |