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;
const int MAX=3*1e3+7;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
string greed[MAX];
int n, m;
cin >> n >> m;
for (int i=1; i<=n; i++){
cin >> greed[i];
greed[i] += "###";
}
for (int i=0; i<=m+2; i++){
greed[0] += "#";
greed[n+1] += "#";
}
int wyn=0;
for (int i=1; i<=n; i++){
for (int j=0; j<m; j++){
if (greed[i][j] == 'R'){
if ((greed[i][j+1] == 'G') and (greed[i][j+2] == 'W')){
wyn++;
if ((greed[i-1][j+1] == 'R') and (greed[i+1][j+1] == 'W')){
greed[i-1][j+1] = '#';
greed[i][j+1] = '#';
greed[i][j+2] = '#';
}
else{
greed[i][j] = '#';
greed[i][j+1] = '#';
greed[i][j+2] = '#';
}
}
}
else if (greed[i][j] == 'G'){
if ((greed[i-1][j] == 'R') and (greed[i+1][j] == 'W')){
wyn++;
if ((greed[i][j-1] == 'R') and (greed[i][j+1] == 'W')){
greed[i][j] = '#';
greed[i][j+1] = '#';
greed[i-1][j] = '#';
}
else{
greed[i-1][j] = '#';
greed[i][j] = '#';
greed[i+1][j] = '#';
}
}
}
}
}
cout << wyn << "\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... |