結果

問題 No.402 最も海から遠い場所
ユーザー titiatitia
提出日時 2023-03-20 01:35:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 1,343 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 448,908 KB
最終ジャッジ日時 2023-10-18 17:58:02
合計ジャッジ時間 16,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,508 KB
testcase_01 AC 42 ms
55,508 KB
testcase_02 AC 72 ms
70,732 KB
testcase_03 AC 42 ms
55,520 KB
testcase_04 WA -
testcase_05 AC 47 ms
61,568 KB
testcase_06 WA -
testcase_07 AC 43 ms
55,520 KB
testcase_08 AC 43 ms
55,520 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 AC 61 ms
68,680 KB
testcase_12 AC 57 ms
66,396 KB
testcase_13 AC 98 ms
77,460 KB
testcase_14 AC 90 ms
76,732 KB
testcase_15 AC 161 ms
86,016 KB
testcase_16 AC 189 ms
89,828 KB
testcase_17 WA -
testcase_18 TLE -
testcase_19 AC 2,554 ms
448,908 KB
testcase_20 AC 2,568 ms
250,680 KB
testcase_21 AC 2,441 ms
414,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

H,W=map(int,input().split())
MAP=[input() for i in range(H)]

ANS=[[1<<30]*(W+2) for i in range(H+2)]

Q=deque()

for i in range(H+2):
    ANS[i][0]=0
    ANS[i][W+1]=0
    Q.append((i,0))
    Q.append((i,W+1))


for i in range(W+2):
    ANS[0][i]=0
    ANS[0][i]=0
    Q.append((0,i))
    Q.append((0,H+1))

for i in range(H):
    for j in range(W):
        if MAP[i][j]==".":
            Q.append((i+1,j+1))
            ANS[i+1][j+1]=0

while Q:
    x,y=Q.popleft()
    for z in range(x-1,x+2):
        for w in range(y-1,y+2):
            if 0<=z<H+2 and 0<=w<W+2 and ANS[z][w]>ANS[x][y]+1:
                ANS[z][w]=ANS[x][y]+1
                Q.append((z,w))

MAX=0
for ans in ANS:
    MAX=max(MAX,max(ans))

print(MAX)
0