답안 #139819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139819 2019-08-01T13:25:41 Z ae04071 Nautilus (BOI19_nautilus) C++11
100 / 100
176 ms 1016 KB
#include <bits/stdc++.h>
using namespace std;

int n,m,l;
bitset<500> dp[2][500];

char arr[501][501],str[5010];
bitset<500> ta[501];

int main() {
    scanf("%d%d%d",&n,&m,&l);
    for(int i=0;i<n;i++) {
        scanf("%s",arr[i]);
        for(int j=0;j<m;j++) ta[i][j] = arr[i][j]=='.';
    }
    scanf("%s",str);
    for(int k=0;k<l;k++) {
        if(str[k]=='?') str[k] = 15;
        else if(str[k]=='S') str[k]=1;
        else if(str[k]=='N') str[k]=2;
        else if(str[k]=='W') str[k]=4;
        else str[k]=8;
    }

    for(int i=0;i<n;i++) dp[0][i] = ta[i];
    
    int cur=1,pr=0;
    for(int k=0;k<l;k++) {
        for(int i=0;i<n;i++) dp[cur][i].reset();
        for(int i=0;i<n;i++) {
            if(i && (str[k]&1)) dp[cur][i] |= dp[pr][i-1];
            if(i<n-1 && (str[k]>>1&1)) dp[cur][i] |= dp[pr][i+1];
            if(str[k]>>2&1) dp[cur][i] |= (dp[pr][i]>>1);
            if(str[k]>>3&1) dp[cur][i] |= (dp[pr][i]<<1);
            dp[cur][i] &= ta[i];
        }
        swap(cur,pr);
    }

    int ans=0;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++) if(dp[pr][i][j]) ans++;
    printf("%d\n",ans);
    
    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&l);
     ~~~~~^~~~~~~~~~~~~~~~~~~
nautilus.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",arr[i]);
         ~~~~~^~~~~~~~~~~~~
nautilus.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",str);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 99 ms 704 KB Output is correct
23 Correct 99 ms 960 KB Output is correct
24 Correct 99 ms 1016 KB Output is correct
25 Correct 97 ms 888 KB Output is correct
26 Correct 96 ms 888 KB Output is correct
27 Correct 140 ms 892 KB Output is correct
28 Correct 143 ms 888 KB Output is correct
29 Correct 142 ms 1016 KB Output is correct
30 Correct 142 ms 1016 KB Output is correct
31 Correct 140 ms 956 KB Output is correct
32 Correct 176 ms 960 KB Output is correct
33 Correct 174 ms 888 KB Output is correct
34 Correct 176 ms 992 KB Output is correct
35 Correct 175 ms 888 KB Output is correct
36 Correct 174 ms 888 KB Output is correct