답안 #725330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725330 2023-04-17T09:47:32 Z Rafi22 Nautilus (BOI19_nautilus) C++14
100 / 100
250 ms 1000 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

const int N=507;

int d[4];
char x[4]={'S','N','W','E'};
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};

int n,m,k;

bool good(int x,int y)
{
    if(min(x,y)>=0&&x<n&&y<m) return 1;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin>>n>>m>>k;
    bitset<N*N>is,A;
    d[0]=-m;
    d[1]=m;
    d[2]=1;
    d[3]=-1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>c;
            if(c=='.') A[i*m+j]=1;
        }
    }
    is=A;
    while(k--)
    {
        cin>>c;
        bitset<N*N>nis;
        if(c=='N') nis=is>>m;
        if(c=='S') nis=is<<m;
        if(c=='E') nis=is<<1;
        if(c=='W') nis=is>>1;
        if(c=='?') nis=(is>>m)|(is<<m)|(is>>1)|(is<<1);
        for(int i=0;i<n;i++)
        {
            nis[i*m]=0;
            nis[i*m+m-1]=0;
            for(int j=0;j<4;j++)
            {
                if(c==x[j]||c=='?')
                {
                    if(good(i+dx[j],0+dy[j])&&is[i*m+d[j]]) nis[i*m]=1;
                    if(good(i+dx[j],m-1+dy[j])&&is[i*m+m-1+d[j]]) nis[i*m+m-1]=1;
                }
            }
        }
        is=nis;
        is&=A;
    }
    cout<<is.count();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 3 ms 636 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 4 ms 596 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 4 ms 672 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 7 ms 596 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 5 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 3 ms 636 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 4 ms 596 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 4 ms 672 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 7 ms 596 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 5 ms 596 KB Output is correct
22 Correct 122 ms 900 KB Output is correct
23 Correct 134 ms 892 KB Output is correct
24 Correct 123 ms 892 KB Output is correct
25 Correct 121 ms 900 KB Output is correct
26 Correct 117 ms 852 KB Output is correct
27 Correct 194 ms 896 KB Output is correct
28 Correct 202 ms 852 KB Output is correct
29 Correct 205 ms 964 KB Output is correct
30 Correct 177 ms 852 KB Output is correct
31 Correct 171 ms 896 KB Output is correct
32 Correct 226 ms 1000 KB Output is correct
33 Correct 240 ms 896 KB Output is correct
34 Correct 250 ms 972 KB Output is correct
35 Correct 225 ms 852 KB Output is correct
36 Correct 230 ms 896 KB Output is correct