結果
問題 | No.402 最も海から遠い場所 |
ユーザー | kohei2019 |
提出日時 | 2022-01-20 23:56:30 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 723 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 858,428 KB |
最終ジャッジ日時 | 2024-05-03 10:58:50 |
合計ジャッジ時間 | 12,064 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
62,264 KB |
testcase_01 | AC | 46 ms
61,568 KB |
testcase_02 | AC | 57 ms
66,816 KB |
testcase_03 | AC | 39 ms
53,888 KB |
testcase_04 | AC | 45 ms
61,184 KB |
testcase_05 | AC | 50 ms
63,104 KB |
testcase_06 | AC | 39 ms
54,144 KB |
testcase_07 | AC | 40 ms
54,016 KB |
testcase_08 | AC | 39 ms
54,144 KB |
testcase_09 | AC | 47 ms
61,568 KB |
testcase_10 | AC | 47 ms
62,464 KB |
testcase_11 | AC | 58 ms
67,200 KB |
testcase_12 | AC | 53 ms
63,872 KB |
testcase_13 | AC | 93 ms
78,976 KB |
testcase_14 | AC | 81 ms
75,180 KB |
testcase_15 | AC | 249 ms
95,616 KB |
testcase_16 | AC | 355 ms
103,100 KB |
testcase_17 | TLE | - |
testcase_18 | MLE | - |
testcase_19 | AC | 1,866 ms
452,504 KB |
testcase_20 | MLE | - |
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)] 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() for dx,dy in dxy: if 0<=x+dx<H and 0<= y+dy <W: 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)