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 n,m;
string s[3005];
bool choosed[3004][3005];
bool up(int x,int y){
if (x < 3) return 0;
if (s[x-2][y] == 'R' && s[x-1][y] == 'G' && s[x][y] == 'W' && !choosed[x-2][y] && !choosed[x-1][y] && !choosed[x][y]){
choosed[x-2][y] = choosed[x-1][y] = choosed[x][y] = 1;
return 1;
}
return 0;
}
bool right(int x,int y){
if (y >= m-1) return 0;
if (s[x][y] == 'R' && s[x][y+1] == 'G' && s[x][y+2] == 'W' && !choosed[x][y] && !choosed[x][y+1] && !choosed[x][y+2]){
choosed[x][y] = choosed[x][y+1] = choosed[x][y+2] = 1;
return 1;
}
return 0;
}
int main(){
iostream::sync_with_stdio(0);
cin >> n >> m;
for(int i=1;i<=n;i++) cin >> s[i], s[i] = '0' + s[i];
int ans = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
ans += up(i,j);
for(int j=1;j<=m;j++)
ans += right(i,j);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |