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=1; i<=n; i++)
for(j=1; j<=m; j++)cin>>a[i][j];
for(i=1; i<=n; i++){
for(j=1; j<=m; j++){
if(a[i][j]!='R')continue;
if(j<=m-2 && used[i][j+1]==0 && used[i][j+2]==0 && a[i][j+1]=='G' && a[i][j+2]=='W')ans++;
else{
if(i<=n-2){
if(a[i+1][j]=='G' && a[i+2][j]=='W'){
if(j>1 && j<n && 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... |