結果
問題 | No.402 最も海から遠い場所 |
ユーザー | kohei2019 |
提出日時 | 2022-01-20 23:54:48 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 878 bytes |
コンパイル時間 | 691 ms |
コンパイル使用メモリ | 87,256 KB |
実行使用メモリ | 518,632 KB |
最終ジャッジ日時 | 2023-08-16 01:00:12 |
合計ジャッジ時間 | 11,393 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
75,968 KB |
testcase_01 | AC | 89 ms
71,580 KB |
testcase_02 | AC | 113 ms
77,724 KB |
testcase_03 | AC | 88 ms
71,584 KB |
testcase_04 | AC | 90 ms
71,516 KB |
testcase_05 | AC | 90 ms
71,876 KB |
testcase_06 | AC | 91 ms
71,816 KB |
testcase_07 | AC | 92 ms
71,696 KB |
testcase_08 | AC | 88 ms
71,580 KB |
testcase_09 | AC | 92 ms
71,860 KB |
testcase_10 | AC | 92 ms
71,836 KB |
testcase_11 | AC | 119 ms
77,428 KB |
testcase_12 | AC | 106 ms
77,316 KB |
testcase_13 | AC | 160 ms
81,448 KB |
testcase_14 | AC | 140 ms
78,528 KB |
testcase_15 | AC | 262 ms
100,444 KB |
testcase_16 | AC | 289 ms
94,964 KB |
testcase_17 | AC | 2,579 ms
462,500 KB |
testcase_18 | MLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import collections H,W = map(int,input().split()) lsHW = ['.'*(W+2)]+['.'+input()+'.' for i in range(H)]+['.'*(W+2)] H += 2 W += 2 INF = 5000 cost = [[INF]*(W) for i in range(H)] used = [[False]*(W) for i in range(H)] dxy = [(0,1),(1,0),(-1,0),(0,-1),(1,1),(-1,1),(1,-1),(-1,-1)] d = collections.deque() for i in range(H): for j in range(W): if lsHW[i][j] == '.': cost[i][j] = 0 d.append((i,j)) while d: x,y = d.popleft() if used[x][y]: continue used[x][y] = True for dx,dy in dxy: if 0<=x+dx<H and 0<= y+dy <W: if used[x+dx][y+dy]: continue if cost[x+dx][y+dy] >= cost[x][y] + 1: cost[x+dx][y+dy] = cost[x][y] + 1 d.append((x+dx,y+dy)) cmax = 0 for i in range(H): for j in range(W): cmax = max(cmax,cost[i][j]) print(cmax)