# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260322 | arnold518 | Nautilus (BOI19_nautilus) | C++14 | 260 ms | 157816 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 500;
const int MAXM = 5000;
int R, C, M;
char S[MAXN+10][MAXN+10];
char A[MAXM+10];
bitset<501> B[MAXN+10];
bitset<501> D[MAXN+10][MAXM+10];
int main()
{
scanf("%d%d%d", &R, &C, &M);
for(int i=1; i<=R; i++) scanf("%s", S[i]+1);
scanf("%s", A+1);
for(int i=1; i<=R; i++) for(int j=1; j<=C; j++) if(S[i][j]=='.') B[i][j-1]=1;
for(int i=1; i<=R; i++) D[i][0]=B[i];
for(int p=1; p<=M; p++)
{
if(A[p]=='N' || A[p]=='?')
{
for(int i=1; i<R; i++)
{
D[i][p]|=D[i+1][p-1];
}
}
if(A[p]=='S' || A[p]=='?')
{
for(int i=2; i<=R; i++)
{
D[i][p]|=D[i-1][p-1];
}
}
if(A[p]=='E' || A[p]=='?')
{
for(int i=1; i<=R; i++)
{
D[i][p]|=D[i][p-1]<<1;
}
}
if(A[p]=='W' || A[p]=='?')
{
for(int i=1; i<=R; i++)
{
D[i][p]|=D[i][p-1]>>1;
}
}
for(int i=1; i<=R; i++) D[i][p]&=B[i];
}
int ans=0;
for(int i=1; i<=R; i++) ans+=D[i][M].count();
printf("%d\n", ans);
}
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... |