# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
216076 | MKopchev | Nautilus (BOI19_nautilus) | C++14 | 359 ms | 760 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 nmax=500+5;
int n,m,k;
bitset<nmax> can[nmax],current[nmax],help[nmax],idle;
int main()
{
scanf("%i%i%i",&n,&m,&k);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
char c=getchar();
while(c!='.'&&c!='#')c=getchar();
if(c=='.')can[i][j]=1;
}
for(int i=1;i<=n;i++)
current[i]=can[i];
for(int i=1;i<=k;i++)
{
char c=getchar();
while(c!='W'&&c!='E'&&c!='S'&&c!='N'&&c!='?')c=getchar();
for(int p=1;p<=n;p++)
help[p]=idle;
if(c=='N'||c=='?')
{
for(int p=1;p<=n;p++)
help[p]=help[p]|current[p+1];
}
if(c=='S'||c=='?')
{
for(int p=1;p<=n;p++)
help[p]=help[p]|current[p-1];
}
if(c=='E'||c=='?')
{
for(int p=1;p<=n;p++)
help[p]=help[p]|(current[p]<<1);
}
if(c=='W'||c=='?')
{
for(int p=1;p<=n;p++)
help[p]=help[p]|(current[p]>>1);
}
for(int p=1;p<=n;p++)
current[p]=help[p]&can[p];
/*
int output=0;
for(int p=1;p<=n;p++)
output=output+current[p].count();
printf("%i\n",output);
cout<<"current "<<endl;
for(int p=1;p<=n;p++)
{
for(int q=1;q<=m;q++)cout<<current[p][q]<<" ";
cout<<endl;
}
cout<<"help "<<endl;
for(int p=1;p<=n;p++)
{
for(int q=1;q<=m;q++)cout<<help[p][q]<<" ";
cout<<endl;
}
cout<<"---"<<endl;
*/
}
int output=0;
for(int p=1;p<=n;p++)
output=output+current[p].count();
printf("%i\n",output);
return 0;
}
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... |