結果
問題 | No.402 最も海から遠い場所 |
ユーザー | kohei2019 |
提出日時 | 2022-01-20 23:54:48 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 878 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 82,944 KB |
実行使用メモリ | 567,060 KB |
最終ジャッジ日時 | 2024-05-03 10:57:22 |
合計ジャッジ時間 | 10,177 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
59,648 KB |
testcase_01 | MLE | - |
testcase_02 | AC | 67 ms
69,376 KB |
testcase_03 | AC | 42 ms
53,888 KB |
testcase_04 | AC | 43 ms
54,528 KB |
testcase_05 | AC | 42 ms
54,144 KB |
testcase_06 | AC | 42 ms
54,016 KB |
testcase_07 | AC | 41 ms
53,888 KB |
testcase_08 | AC | 46 ms
54,144 KB |
testcase_09 | AC | 43 ms
54,656 KB |
testcase_10 | AC | 44 ms
54,272 KB |
testcase_11 | AC | 69 ms
70,912 KB |
testcase_12 | AC | 59 ms
65,280 KB |
testcase_13 | AC | 117 ms
78,736 KB |
testcase_14 | AC | 100 ms
77,444 KB |
testcase_15 | AC | 210 ms
93,440 KB |
testcase_16 | AC | 255 ms
99,684 KB |
testcase_17 | TLE | - |
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)