結果

問題 No.402 最も海から遠い場所
ユーザー 👑 H20H20
提出日時 2021-12-08 16:46:57
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,134 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 643,100 KB
最終ジャッジ日時 2023-09-23 08:11:05
合計ジャッジ時間 9,398 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
81,260 KB
testcase_01 AC 98 ms
76,876 KB
testcase_02 AC 119 ms
78,000 KB
testcase_03 AC 89 ms
71,712 KB
testcase_04 AC 91 ms
71,664 KB
testcase_05 AC 100 ms
77,032 KB
testcase_06 AC 87 ms
71,400 KB
testcase_07 AC 89 ms
71,592 KB
testcase_08 AC 89 ms
71,664 KB
testcase_09 AC 98 ms
76,952 KB
testcase_10 AC 94 ms
75,168 KB
testcase_11 AC 119 ms
77,284 KB
testcase_12 AC 115 ms
77,444 KB
testcase_13 AC 166 ms
82,048 KB
testcase_14 AC 148 ms
79,080 KB
testcase_15 AC 323 ms
106,284 KB
testcase_16 AC 354 ms
107,812 KB
testcase_17 MLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
H,W = map(int,input().split())
H+=2
W+=2
MAP = []
MAP.append(list([0]*W))
for _ in range(H-2):
    S = list(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)]

deqx = collections.deque()
deqy = 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:
                    deqx.append(x)
                    deqy.append(y)
cnt = -1
while len(deqx):
    cnt+=1
    ndeqx = collections.deque()
    ndeqy = collections.deque()
    while len(deqx):
        i = deqx.pop()
        j = deqy.pop()
        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
                ndeqx.append(x)
                ndeqy.append(y)
    deqx = ndeqx
    deqy = ndeqy
print(cnt)




0