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 <iostream>
#include <fstream>
#include <bitset>
using namespace std;
const int nmax=1005;
string s,mov;
bitset<nmax> can[nmax],niu[nmax],ok[nmax];
int n,m,k,i,j,mv;
int main()
{
ios_base::sync_with_stdio(false);
cin>>n>>m>>k;
for(i=1;i<=n;i++)
{
cin>>s;
for(j=0;j<m;j++)
{
if(s[j]=='.')
{
ok[i][j]=1,can[i][j]=1;
}
}
}
cin>>mov;
for(int mv=0;mv<mov.size();mv++)
{
if(mov[mv]=='N')
{
for(i=1;i<=n+1;i++)
can[i-1]=((can[i]&ok[i-1]));
}
if(mov[mv]=='S')
{
for(i=n;i>=0;i--)
can[i+1]=(can[i]&ok[i+1]);
}
if(mov[mv]=='E')
{
for(i=1;i<=n;i++)
can[i]=((can[i]<<1)&ok[i]);
}
if(mov[mv]=='W')
{
for(i=1;i<=n;i++)
can[i]=((can[i]>>1)&ok[i]);
}
if(mov[mv]=='?')
{
for(i=1;i<=n;i++)
niu[i]=((can[i-1]|can[i+1]|(can[i]>>1)|(can[i]<<1))&ok[i]);
for(i=1;i<=n;i++)
can[i]=niu[i];
}
}
int ans=0;
for(i=1;i<=n;i++)
ans+=can[i].count();
cout<<ans;
return 0;
}
Compilation message (stderr)
nautilus.cpp: In function 'int main()':
nautilus.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int mv=0;mv<mov.size();mv++)
~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |