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;
void solve() {
int n, m;
cin >> n >> m;
vector<string> grid(n);
for(int i=0;i<n;i++) cin >> grid[i];
int ans = 0;
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
if(j + 2 < m && grid[i][j] == 'R' && grid[i][j+1] == 'G' && grid[i][j+2] == 'W') {
grid[i][j] = 'P';
grid[i][j+1] = 'P';
grid[i][j+2] = 'P';
ans++;
}
if(i + 2 < n && grid[i][j] == 'R' && grid[i+1][j] == 'G' && grid[i+2][j] == 'W') {
grid[i][j] = 'P';
grid[i+1][j] = 'P';
grid[i+2][j] = 'P';
ans++;
}
}
}
cout << ans;
}
int main() {
solve();
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... |