結果
問題 | No.2412 YOU Grow Bigger! |
ユーザー | 👑 AngrySadEight |
提出日時 | 2023-07-20 00:21:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,953 ms / 6,000 ms |
コード長 | 2,625 bytes |
コンパイル時間 | 222 ms |
コンパイル使用メモリ | 82,188 KB |
実行使用メモリ | 123,484 KB |
最終ジャッジ日時 | 2024-11-21 08:41:22 |
合計ジャッジ時間 | 15,553 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
55,856 KB |
testcase_01 | AC | 40 ms
55,828 KB |
testcase_02 | AC | 51 ms
64,512 KB |
testcase_03 | AC | 1,759 ms
123,484 KB |
testcase_04 | AC | 1,749 ms
123,096 KB |
testcase_05 | AC | 1,335 ms
105,648 KB |
testcase_06 | AC | 1,953 ms
114,932 KB |
testcase_07 | AC | 1,767 ms
123,092 KB |
testcase_08 | AC | 1,720 ms
115,008 KB |
testcase_09 | AC | 57 ms
67,856 KB |
testcase_10 | AC | 129 ms
76,992 KB |
testcase_11 | AC | 57 ms
67,536 KB |
testcase_12 | AC | 46 ms
60,580 KB |
testcase_13 | AC | 157 ms
77,500 KB |
testcase_14 | AC | 89 ms
76,720 KB |
testcase_15 | AC | 53 ms
65,772 KB |
testcase_16 | AC | 57 ms
67,868 KB |
testcase_17 | AC | 62 ms
69,780 KB |
testcase_18 | AC | 324 ms
80,708 KB |
testcase_19 | AC | 53 ms
65,256 KB |
testcase_20 | AC | 57 ms
67,612 KB |
testcase_21 | AC | 130 ms
76,684 KB |
testcase_22 | AC | 152 ms
77,260 KB |
testcase_23 | AC | 553 ms
84,316 KB |
testcase_24 | AC | 886 ms
91,912 KB |
testcase_25 | AC | 467 ms
83,560 KB |
testcase_26 | AC | 120 ms
77,052 KB |
testcase_27 | AC | 104 ms
76,760 KB |
testcase_28 | AC | 205 ms
78,272 KB |
testcase_29 | AC | 55 ms
67,008 KB |
testcase_30 | AC | 45 ms
61,368 KB |
ソースコード
from collections import deque def main(): H, W = map(int, input().split()) S = [] for _ in range(H): S.append(input()) que = deque([(0, 0)]) isvisited = [[False for _ in range(W - 2)] for _ in range(H - 2)] isvisited[0][0] = True dx = [1, 1, 0, -1, -1, -1, 0, 1] dy = [0, 1, 1, 1, 0, -1, -1, -1] pos = [[True for _ in range(W - 2)] for _ in range(H - 2)] for i in range(H - 2): for j in range(W - 2): for k in range(3): for l in range(3): if S[i + k][j + l] == "#": pos[i][j] = False while que: p = que.popleft() for i in range(8): if 0 <= p[0] + dx[i] < H - 2 and 0 <= p[1] + dy[i] < W - 2: if isvisited[p[0] + dx[i]][p[1] + dy[i]]: continue if pos[p[0] + dx[i]][p[1] + dy[i]]: isvisited[p[0] + dx[i]][p[1] + dy[i]] = True que.append((p[0] + dx[i], p[1] + dy[i])) if not isvisited[H - 3][W - 3]: print(0) return for i in range(H): for j in range(W): if S[i][j] == "#": continue if 0 <= i <= 2 and 0 <= j <= 2: continue if H - 3 <= i < H and W - 3 <= j < W: continue S[i] = S[i][:j] + "#" + S[i][j + 1 :] que.append((0, 0)) for k in range(H - 2): for l in range(W - 2): isvisited[k][l] = False isvisited[0][0] = True for k in range(H - 2): for l in range(W - 2): pos[k][l] = True for k in range(H - 2): for l in range(W - 2): for m in range(3): for n in range(3): if S[k + m][l + n] == "#": pos[k][l] = False while que: p = que.popleft() for k in range(8): if 0 <= p[0] + dx[k] < H - 2 and 0 <= p[1] + dy[k] < W - 2: if isvisited[p[0] + dx[k]][p[1] + dy[k]]: continue if pos[p[0] + dx[k]][p[1] + dy[k]]: isvisited[p[0] + dx[k]][p[1] + dy[k]] = True que.append((p[0] + dx[k], p[1] + dy[k])) if not isvisited[H - 3][W - 3]: print(1) return S[i] = S[i][:j] + "." + S[i][j + 1 :] print(2) if __name__ == "__main__": main()