結果
問題 | No.402 最も海から遠い場所 |
ユーザー |
![]() |
提出日時 | 2021-02-13 15:13:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,672 ms / 3,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 451,840 KB |
最終ジャッジ日時 | 2024-07-20 18:01:01 |
合計ジャッジ時間 | 14,025 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
h,w = map(int,input().split())b = ["."*(w+2)]for _ in range(h):b.append("."+input()+".")b += ["."*(w+2)]h += 2; w += 2dist = [[-1]*w for _ in range(h)]from collections import dequeq = deque()for i in range(h):for j in range(w):if b[i][j] == ".":q.append((i,j))dist[i][j] = 0while q:i,j = q.popleft()for di in range(-1,2):for dj in range(-1,2):ni = i+dinj = j+djif 0 <= ni < h and 0 <= nj < w and dist[ni][nj] == -1:dist[ni][nj] = dist[i][j] + 1q.append((ni,nj))print(dist[i][j])