답안 #130975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130975 2019-07-16T10:40:45 Z PeppaPig Nautilus (BOI19_nautilus) C++14
100 / 100
222 ms 1016 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 505;
const int M = 5e3+5;

int r, c, m;
char a[N][N], dir[M];
bitset<N> mask[N], dp[N];

int main() {
    scanf("%d %d %d", &r, &c, &m);
    for(int i = 0; i < r; i++) {
        scanf(" %s", a[i]);
        for(int j = 0; j < c; j++) {
            if(a[i][j] == '#') mask[i][j] = dp[i][j] = 0;
            else mask[i][j] = dp[i][j] = 1;
        }
    }
    scanf(" %s", dir);
    for(int i = 0; i < m; i++) {
        bitset<N> ndp[N];
        for(int j = 0; j < r; j++) ndp[j] = 0;
        if(dir[i] == 'N' || dir[i] == '?') for(int j = 0; j < r - 1; j++)
            ndp[j] |= dp[j + 1];
        if(dir[i] == 'S' || dir[i] == '?') for(int j = 1; j < r; j++)
            ndp[j] |= dp[j - 1];
        if(dir[i] == 'W' || dir[i] == '?') for(int j = 0; j < r; j++)
            ndp[j] |= dp[j] >> 1;
        if(dir[i] == 'E' || dir[i] == '?') for(int j = 0; j < r; j++)
            ndp[j] |= dp[j] << 1;
        for(int j = 0; j < r; j++) dp[j] = ndp[j] & mask[j];
    }
    int ans = 0;
    for(int i = 0; i < r; i++) ans += dp[i].count();
    printf("%d\n", ans);

    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &r, &c, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", a[i]);
         ~~~~~^~~~~~~~~~~~~
nautilus.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", dir);
     ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 504 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 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 504 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 147 ms 984 KB Output is correct
23 Correct 144 ms 992 KB Output is correct
24 Correct 138 ms 888 KB Output is correct
25 Correct 140 ms 888 KB Output is correct
26 Correct 137 ms 960 KB Output is correct
27 Correct 183 ms 956 KB Output is correct
28 Correct 193 ms 888 KB Output is correct
29 Correct 186 ms 1016 KB Output is correct
30 Correct 190 ms 1016 KB Output is correct
31 Correct 184 ms 956 KB Output is correct
32 Correct 218 ms 956 KB Output is correct
33 Correct 219 ms 956 KB Output is correct
34 Correct 221 ms 888 KB Output is correct
35 Correct 221 ms 952 KB Output is correct
36 Correct 222 ms 952 KB Output is correct