結果
問題 | No.402 最も海から遠い場所 |
ユーザー | kohei2019 |
提出日時 | 2022-01-21 00:03:46 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 829 bytes |
コンパイル時間 | 289 ms |
コンパイル使用メモリ | 87,168 KB |
実行使用メモリ | 258,472 KB |
最終ジャッジ日時 | 2023-08-16 01:09:40 |
合計ジャッジ時間 | 9,159 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
75,796 KB |
testcase_01 | WA | - |
testcase_02 | AC | 105 ms
77,624 KB |
testcase_03 | AC | 85 ms
71,676 KB |
testcase_04 | AC | 86 ms
71,620 KB |
testcase_05 | AC | 85 ms
71,764 KB |
testcase_06 | AC | 84 ms
71,668 KB |
testcase_07 | WA | - |
testcase_08 | AC | 85 ms
71,756 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 97 ms
77,332 KB |
testcase_12 | WA | - |
testcase_13 | AC | 125 ms
78,496 KB |
testcase_14 | AC | 114 ms
78,056 KB |
testcase_15 | AC | 199 ms
86,816 KB |
testcase_16 | AC | 234 ms
91,244 KB |
testcase_17 | WA | - |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import collections import sys input = sys.stdin.readline def main(): 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)) cmax = 0 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 cmax = cost[x][y] + 1 d.append((x+dx,y+dy)) print(cmax) main()