結果

問題 No.402 最も海から遠い場所
ユーザー 👑 H20H20
提出日時 2021-12-08 16:42:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 975 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 470,948 KB
最終ジャッジ日時 2023-09-23 08:09:14
合計ジャッジ時間 12,822 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
77,728 KB
testcase_01 AC 126 ms
77,716 KB
testcase_02 AC 148 ms
78,836 KB
testcase_03 AC 121 ms
72,972 KB
testcase_04 AC 122 ms
72,840 KB
testcase_05 AC 134 ms
77,728 KB
testcase_06 AC 118 ms
73,020 KB
testcase_07 AC 121 ms
72,856 KB
testcase_08 AC 119 ms
72,924 KB
testcase_09 AC 130 ms
77,536 KB
testcase_10 AC 123 ms
75,496 KB
testcase_11 AC 155 ms
78,836 KB
testcase_12 AC 143 ms
78,456 KB
testcase_13 AC 193 ms
82,500 KB
testcase_14 AC 181 ms
80,024 KB
testcase_15 AC 332 ms
100,192 KB
testcase_16 AC 362 ms
100,264 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import copy
H,W = map(int,input().split())
H+=2
W+=2
MAP = []
MAP.append(list([0]*W))
for _ in range(H-2):
    S = input()
    L = [0]*W
    for i in range(1,W-1):
        if S[i-1]=='#':
            L[i]=1
    MAP.append(L)
MAP.append(list([0]*W))

CNT = [[10000]*W for _ in range(H)]

deq = collections.deque()
X = [0,1,0,-1,1,-1,1,-1]
Y = [1,0,-1,0,1,-1,-1,1]
for i in range(H):
    for j in range(W):
        if MAP[i][j]==1:
            for k in range(8):
                x = i+X[k]
                y = j+Y[k]
                if 0<=x<H and 0<=y<W and MAP[x][y]==0:
                    deq.append((x,y))
cnt = -1
while len(deq):
    cnt+=1
    ndeq = collections.deque()
    while len(deq):
        i,j = deq.popleft()
        MAP[i][j]=0
        for k in range(8):
            x = i+X[k]
            y = j+Y[k]
            if 0<=x<H and 0<=y<W and MAP[x][y]==1:
                MAP[x][y]=0
                ndeq.append((x,y))
    deq = ndeq
print(cnt)
0