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>
#include <vector>
using namespace std;
bool odw[3001][3001];
int main()
{
int64_t n,m;
cin >> n >> m;
int64_t wyn=0;
vector<string> v(n);
for (int64_t i=0; i<n; i++) cin >> v[i];
for (int64_t i=0; i<n; i++){
for (int64_t j=0; j<m; j++){
//cout << i << ' ' << j << '\n';
if (v[i][j]=='R' and v[i][min(j+1,m-1)]=='G' and v[i][min(j+2,m-1)]=='W' and !odw[i][j] and !odw[i][min(j+1,n-1)] and !odw[i][min(j+2,m-1)]){
if (v[i][min(j+1,m-1)]=='G' and v[max(i-1,int64_t(0))][min(j+1,m-1)]=='R' and v[min(i+1,n-1)][min(j+1,m-1)]=='W' and !odw[i][min(j+1,m-1)] and !odw[max(i-1,int64_t(0))][min(j+1,m-1)] and !odw[min(i+1,n-1)][min(j+1,m-1)]){
odw[i][j+1]=odw[i][j+2]=odw[i+1][j+1]=1;
wyn++;
}
else{
//cout << i << ' ' << j << '\n';
odw[i][j]=odw[i][j+1]=odw[i][j+2]=1;
wyn++;
}
}
else if (v[i][j]=='G' and v[max(i-1,int64_t(0))][j]=='R' and v[min(i+1,n-1)][j]=='W' and !odw[i][j] and !odw[max(i-1,int64_t(0))][j] and !odw[min(i+1,n-1)][j]){
//cout << i << ' ' << j << '\n';
odw[i][j]=odw[i-1][j]=odw[i+1][j]=1;
wyn++;
}
}
}
cout << wyn;
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... |