Submission #393453

# Submission time Handle Problem Language Result Execution time Memory
393453 2021-04-23T13:41:22 Z inventiontime Nautilus (BOI19_nautilus) C++17
100 / 100
216 ms 708 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;

int R, C, M;
bitset<502> W[502] = {};
bitset<502> pos[2][502] = {};
queue<ii> pts;
string I;

int main() {
    cin >> R >> C >> M;

    char c;
    for(int i = 1; i <= R; i++) for(int j = 1; j <= C; j++) {
        cin >> c;
        W[i][j] = c == '.';
        pos[1][i][j] = W[i][j];
    }

    cin >> I;
    for(int k = 0; k < M; k++)
        for(int i = 1; i <= R; i++) {
            switch(I[k]) {
                case 'N':
                pos[k % 2][i] = pos[(k % 2) ^ 1][i+1] & W[i];
                break;

                case 'S':
                pos[k % 2][i] = pos[(k % 2) ^ 1][i-1] & W[i];
                break;

                case 'E':
                pos[k % 2][i] = pos[(k % 2) ^ 1][i] << 1 & W[i];
                break;

                case 'W':
                pos[k % 2][i] = pos[(k % 2) ^ 1][i] >> 1 & W[i];
                break;

                case '?':
                pos[k % 2][i] = (
                      (pos[(k % 2) ^ 1][i] << 1)
                    | (pos[(k % 2) ^ 1][i] >> 1)
                    | pos[(k % 2) ^ 1][i-1]
                    | pos[(k % 2) ^ 1][i+1]) & W[i];
                break;
            }
        }

    int res = 0;
    for(int i = 1; i <= R; i++) for(int j = 1; j <= C; j++) {
        if(pos[(M % 2) ^ 1][i][j])
            res++;
    }

    cout << res << endl;

    return 0;
}

/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 304 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 304 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 107 ms 636 KB Output is correct
23 Correct 111 ms 580 KB Output is correct
24 Correct 109 ms 640 KB Output is correct
25 Correct 109 ms 636 KB Output is correct
26 Correct 112 ms 632 KB Output is correct
27 Correct 172 ms 632 KB Output is correct
28 Correct 164 ms 588 KB Output is correct
29 Correct 166 ms 632 KB Output is correct
30 Correct 171 ms 708 KB Output is correct
31 Correct 166 ms 632 KB Output is correct
32 Correct 207 ms 568 KB Output is correct
33 Correct 208 ms 588 KB Output is correct
34 Correct 216 ms 708 KB Output is correct
35 Correct 207 ms 588 KB Output is correct
36 Correct 206 ms 592 KB Output is correct