답안 #123011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123011 2019-06-30T01:45:23 Z model_code Nautilus (BOI19_nautilus) Python 3
66 / 100
1000 ms 3640 KB
import sys

r,c,m = [int(x) for x in sys.stdin.readline().split()]
grid = [sys.stdin.readline() for i in range(r)]
msg = sys.stdin.readline()
reach,sea,tmp = [0 for i in range(r)],\
                [0 for i in range(r)],\
                [0 for i in range(r)]
for i in range(r):
    for j in range(c):
        sea[i] *= 2
        sea[i] += grid[i][j] == '.'
    reach[i] = sea[i]
ans = 0
for w in msg:
    for i in range(r):
        if w == 'W':
            reach[i] = (reach[i] << 1)&sea[i]
        if w == 'E':
            reach[i] = (reach[i] >> 1)&sea[i]
        if w == 'N':
            reach[i] = reach[i+1]&sea[i] if i+1 < r else 0
        if w == '?':
            tmp[i] = (reach[i] << 1)|(reach[i] >> 1)
            if i:
                tmp[i] |= reach[i-1]
            if i+1 < r:
                tmp[i] |= reach[i+1]
            tmp[i] &= sea[i]
    for i in range(r-1,-1,-1):
        if w == 'S':
            reach[i] = reach[i-1]&sea[i] if i else 0
    for i in range(r):
        if w == '?':
            reach[i] = tmp[i]

ans = sum([bin(x).count('1') for x in reach])
print(ans)
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3428 KB Output is correct
2 Correct 38 ms 3428 KB Output is correct
3 Correct 39 ms 3464 KB Output is correct
4 Correct 38 ms 3428 KB Output is correct
5 Correct 38 ms 3428 KB Output is correct
6 Correct 38 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3428 KB Output is correct
2 Correct 38 ms 3428 KB Output is correct
3 Correct 39 ms 3464 KB Output is correct
4 Correct 38 ms 3428 KB Output is correct
5 Correct 38 ms 3428 KB Output is correct
6 Correct 38 ms 3428 KB Output is correct
7 Correct 45 ms 3428 KB Output is correct
8 Correct 43 ms 3456 KB Output is correct
9 Correct 43 ms 3428 KB Output is correct
10 Correct 43 ms 3400 KB Output is correct
11 Correct 41 ms 3428 KB Output is correct
12 Correct 46 ms 3428 KB Output is correct
13 Correct 49 ms 3428 KB Output is correct
14 Correct 47 ms 3428 KB Output is correct
15 Correct 48 ms 3428 KB Output is correct
16 Correct 49 ms 3428 KB Output is correct
17 Correct 53 ms 3448 KB Output is correct
18 Correct 50 ms 3428 KB Output is correct
19 Correct 50 ms 3428 KB Output is correct
20 Correct 51 ms 3428 KB Output is correct
21 Correct 51 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3428 KB Output is correct
2 Correct 38 ms 3428 KB Output is correct
3 Correct 39 ms 3464 KB Output is correct
4 Correct 38 ms 3428 KB Output is correct
5 Correct 38 ms 3428 KB Output is correct
6 Correct 38 ms 3428 KB Output is correct
7 Correct 45 ms 3428 KB Output is correct
8 Correct 43 ms 3456 KB Output is correct
9 Correct 43 ms 3428 KB Output is correct
10 Correct 43 ms 3400 KB Output is correct
11 Correct 41 ms 3428 KB Output is correct
12 Correct 46 ms 3428 KB Output is correct
13 Correct 49 ms 3428 KB Output is correct
14 Correct 47 ms 3428 KB Output is correct
15 Correct 48 ms 3428 KB Output is correct
16 Correct 49 ms 3428 KB Output is correct
17 Correct 53 ms 3448 KB Output is correct
18 Correct 50 ms 3428 KB Output is correct
19 Correct 50 ms 3428 KB Output is correct
20 Correct 51 ms 3428 KB Output is correct
21 Correct 51 ms 3428 KB Output is correct
22 Execution timed out 1071 ms 3640 KB Time limit exceeded
23 Halted 0 ms 0 KB -