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 main(){
cin.tie(0)->sync_with_stdio(0);
int n, m; cin >> n >> m;
string g[n];
for (int i = 0; i < n; i++)
cin >> g[i];
bool vis[n][m]{};
int ans = 0;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (g[i][j] != 'W' || vis[i][j]) continue;
if (i - 1 >= 0 && !vis[i - 1][j] && g[i - 1][j] == 'G' && \
i - 2 >= 0 && !vis[i - 2][j] && g[i - 2][j] == 'R'){
vis[i][j] = vis[i - 1][j] = vis[i - 2][j] = 1;
ans++;
}
}
for (int j = 0; j < m; j++){
if (g[i][j] != 'W' || vis[i][j]) continue;
if (j - 1 >= 0 && !vis[i][j - 1] && g[i][j - 1] == 'G' && \
j - 2 >= 0 && !vis[i][j - 2] && g[i][j - 2] == 'R'){
vis[i][j] = vis[i][j - 1] = vis[i][j - 2] = 1;
ans++;
}
}
}
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... |