# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260316 | arnold518 | Nautilus (BOI19_nautilus) | C++14 | 1097 ms | 181760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
ll B[MAXN+10][MAXN+10];
ll D[MAXN+10][MAXN/60+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/60]|=(1ll<<(j%60));
for(int i=1; i<=R; i++) for(int j=0; j<=C/60; j++) D[i][j][0]=B[i][j];
for(int p=1; p<=M; p++)
{
if(A[p]=='N')
{
for(int i=1; i<R; i++) for(int j=0; j<=C/60; j++)
{
D[i][j][p]=D[i+1][j][p-1];
D[i][j][p]&=B[i][j];
}
}
if(A[p]=='S')
{
for(int i=2; i<=R; i++) for(int j=0; j<=C/60; j++)
{
D[i][j][p]=D[i-1][j][p-1];
D[i][j][p]&=B[i][j];
}
}
if(A[p]=='E')
{
for(int i=1; i<=R; i++)
{
for(int j=C/60; j>=0; j--)
{
D[i][j][p]=D[i][j][p-1]<<1;
D[i][j][p]&=((1ll<<60)-1);
if(j!=0 && (D[i][j-1][p-1]&(1ll<<59))) D[i][j][p]|=1;
D[i][j][p]&=B[i][j];
}
}
}
if(A[p]=='W')
{
for(int i=1; i<=R; i++)
{
for(int j=0; j<=C/60; j++)
{
D[i][j][p]=D[i][j][p-1]>>1;
if(j!=C/60 && (D[i][j+1][p-1]&1)) D[i][j][p]|=(1ll<<59);
D[i][j][p]&=B[i][j];
}
}
}
if(A[p]=='?')
{
for(int i=1; i<=R; i++) for(int j=0; j<=C/60; j++)
{
if(i!=R) D[i][j][p]|=D[i+1][j][p-1];
if(i!=1) D[i][j][p]|=D[i-1][j][p-1];
}
for(int i=1; i<=R; i++)
{
for(int j=C/60; j>=0; j--)
{
ll t;
t=D[i][j][p-1]<<1;
t&=((1ll<<60)-1);
if(j!=0 && (D[i][j-1][p-1]&(1ll<<59))) t|=1;
D[i][j][p]|=t;
}
}
for(int i=1; i<=R; i++)
{
for(int j=0; j<=C/60; j++)
{
ll t;
t=D[i][j][p-1]>>1;
if(j!=C/60 && (D[i][j+1][p-1]&1)) t|=(1ll<<59);
t&=B[i][j];
D[i][j][p]|=t;
}
}
for(int i=1; i<=R; i++) for(int j=0; j<=C/60; j++) D[i][j][p]&=B[i][j];
}
}
int ans=0;
for(int i=1; i<=R; i++) for(int j=0; j<=C/60; j++) ans+=__builtin_popcountll(D[i][j][M]);
printf("%d\n", ans);
}
컴파일 시 표준 에러 (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... |