結果
問題 | No.402 最も海から遠い場所 |
ユーザー | rlangevin |
提出日時 | 2023-07-16 12:28:10 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 192 ms |
コンパイル使用メモリ | 81,592 KB |
実行使用メモリ | 695,620 KB |
最終ジャッジ日時 | 2023-10-17 14:56:29 |
合計ジャッジ時間 | 9,761 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
55,516 KB |
testcase_01 | AC | 49 ms
55,516 KB |
testcase_02 | AC | 86 ms
68,452 KB |
testcase_03 | AC | 43 ms
55,520 KB |
testcase_04 | AC | 43 ms
55,520 KB |
testcase_05 | AC | 44 ms
55,520 KB |
testcase_06 | AC | 43 ms
55,520 KB |
testcase_07 | AC | 44 ms
55,520 KB |
testcase_08 | AC | 44 ms
55,520 KB |
testcase_09 | AC | 45 ms
55,520 KB |
testcase_10 | AC | 44 ms
55,520 KB |
testcase_11 | AC | 57 ms
64,372 KB |
testcase_12 | AC | 54 ms
64,276 KB |
testcase_13 | AC | 84 ms
78,676 KB |
testcase_14 | AC | 67 ms
70,536 KB |
testcase_15 | AC | 138 ms
90,972 KB |
testcase_16 | AC | 171 ms
97,960 KB |
testcase_17 | AC | 1,664 ms
425,632 KB |
testcase_18 | MLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import sys input = sys.stdin.readline H, W = map(int, input().split()) S = [] S.append(["."] * (W + 2)) for i in range(H): S.append(["."] + list(input().rstrip()) + ["."]) S.append(["."] * (W + 2)) dx = [1, 0, -1, 0, 1, 1, -1, -1] dy = [0, 1, 0, -1, 1, -1, 1, -1] from collections import * Q = deque() dist = [[-1] * (W + 2) for i in range(H + 2)] for i in range(H + 2): for j in range(W + 2): if S[i][j] == ".": dist[i][j] = 0 Q.append((i, j)) ans = 0 while Q: i, j = Q.popleft() for k in range(8): x = i + dx[k] y = j + dy[k] if x < 0 or x > H + 1 or y < 0 or y > W + 1: continue if dist[x][y] != -1: continue dist[x][y] = dist[i][j] + 1 ans = max(ans, dist[x][y]) Q.append((x, y)) print(ans)