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 mod=1e9+7;
int n,m,tk[3030][3030],ans;
char a[3030][3030];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("dec.in","r",stdin);
//freopen("dec.out","w",stdout);
cin>>n>>m;
for(int i=0; i<n; i++)cin>>a[i];
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
if(tk[i][j])continue;
if(a[i][j]=='R'&&a[i+1][j]=='G'&&a[i+2][j]=='W')
{
int num=0;
if(a[i+1][j-1]=='R'&&a[i+1][j+1]=='W')num++;
if(a[i+2][j-2]=='R'&&a[i+2][j-1]=='G')num++;
if(num<=1)
{
ans++;
tk[i][j]++;
tk[i+1][j]++;
tk[i+2][j]++;
}
}
if(a[i][j]=='R'&&a[i][j+1]=='G'&&a[i][j+2]=='W')
{
ans++;
tk[i][j]++;
tk[i][j+1]++;
tk[i][j+2]++;
}
}
}
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... |