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>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
using namespace std;
int n,m,k,i,j,ans,used[3005][3005];
char a[3005][3005];
int main() {
cin>>n>>m;
ans=0;
for(i=0; i<n; i++)cin>>a[i];
for(i=0; i<n; i++){
for(j=0; j<m; j++){
if(a[i][j]!='R')continue;
if(j<m-2){
if(!(used[i][j+1]+used[i][j+2]) && a[i][j+1]=='G' && a[i][j+2]=='W')ans++;
}
if(i<n-2){
if(a[i+1][j]=='G' && a[i+2][j]=='W'){
if(j>0 && j<m-1 && a[i+1][j-1]=='R' && a[i+1][j]=='G' && a[i+1][j+1]=='W')used[i+1][j]=1;
else used[i+2][j]=1;
ans++;
}
}
}
}
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... |