답안 #393445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393445 2021-04-23T13:20:41 Z inventiontime Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 1196 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;

int R, C, M;
bool W[502][502] = {};
bool pos[502][502][2] = {};
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[i][j][1] = W[i][j];
    }

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

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

                case 'E':
                pos[i][j][k % 2] = pos[i][j-1][(k % 2) ^ 1];
                break;

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

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

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

    cout << res << endl;

    return 0;
}

/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 324 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 7 ms 460 KB Output is correct
4 Correct 7 ms 588 KB Output is correct
5 Correct 5 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 324 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 7 ms 460 KB Output is correct
4 Correct 7 ms 588 KB Output is correct
5 Correct 5 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 7 ms 464 KB Output is correct
9 Correct 7 ms 460 KB Output is correct
10 Correct 5 ms 460 KB Output is correct
11 Correct 3 ms 440 KB Output is correct
12 Correct 4 ms 460 KB Output is correct
13 Correct 6 ms 460 KB Output is correct
14 Correct 7 ms 460 KB Output is correct
15 Correct 5 ms 460 KB Output is correct
16 Correct 2 ms 444 KB Output is correct
17 Correct 6 ms 476 KB Output is correct
18 Correct 6 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 5 ms 460 KB Output is correct
21 Correct 2 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 324 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 7 ms 460 KB Output is correct
4 Correct 7 ms 588 KB Output is correct
5 Correct 5 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 7 ms 464 KB Output is correct
9 Correct 7 ms 460 KB Output is correct
10 Correct 5 ms 460 KB Output is correct
11 Correct 3 ms 440 KB Output is correct
12 Correct 4 ms 460 KB Output is correct
13 Correct 6 ms 460 KB Output is correct
14 Correct 7 ms 460 KB Output is correct
15 Correct 5 ms 460 KB Output is correct
16 Correct 2 ms 444 KB Output is correct
17 Correct 6 ms 476 KB Output is correct
18 Correct 6 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 5 ms 460 KB Output is correct
21 Correct 2 ms 440 KB Output is correct
22 Execution timed out 1092 ms 1196 KB Time limit exceeded
23 Halted 0 ms 0 KB -