# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116119 | faustaadp | Dango Maker (JOI18_dango_maker) | C++17 | 241 ms | 56184 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>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,j,has,te;
char a[3030][3030];
int x[9000010];
bool mat[3000010];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
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(j+2<=m&&a[i][j]=='R'&&a[i][j+1]=='G'&&a[i][j+2]=='W')
{
te++;
has++;
x[(i-1)*m+j]=te;
x[(i-1)*m+j+1]=te;
x[(i-1)*m+j+2]=te;
}
}
ll hai=te;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
if(i+2<=n&&a[i][j]=='R'&&a[i+1][j]=='G'&&a[i+2][j]=='W')
{
te++;
has++;
ll udah=0;
if(x[(i-1)*m+j]!=0)
{
if(mat[x[(i-1)*m+j]]==0)
{
mat[x[(i-1)*m+j]]=1;
udah=1;
}
}
if(x[(i)*m+j]!=0)
{
if(mat[x[(i)*m+j]]==0&&udah==0)
{
mat[x[(i)*m+j]]=1;
udah=1;
}
}
if(x[(i+1)*m+j]!=0)
{
if(mat[x[(i+1)*m+j]]==0&&udah==0)
{
mat[x[(i+1)*m+j]]=1;
udah=1;
}
}
has-=udah;
}
}
cout<<has<<"\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |