# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200254 | mdn2002 | Dango Maker (JOI18_dango_maker) | C++14 | 0 ms | 0 KiB |
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(a[i][j]=='R'&&a[i+1][j]=='G'&&a[i+2][j]=='W'&&tk[i][j]+tk[i+1][j]+tk[i+2][j]==0)
{
if(a[i+1][j-1]=='R'&&a[i+1][j+1]=='W'&&a[i+2][j-2]=='R'&&a[i+2][j-1]=='G')num++;
else
{
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'&&tk[i][j]+tk[i][j+1]+tk[i][j+2]==0)
{
ans++;
tk[i][j]++;
tk[i][j+1]++;
tk[i][j+2]++;
}
}
}
cout<<ans;
}