結果

問題 No.402 最も海から遠い場所
ユーザー maspymaspy
提出日時 2020-03-12 21:38:53
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,177 ms / 3,000 ms
コード長 601 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 11,032 KB
実行使用メモリ 152,840 KB
最終ジャッジ日時 2023-08-12 08:32:08
合計ジャッジ時間 11,209 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
29,804 KB
testcase_01 AC 133 ms
29,796 KB
testcase_02 AC 135 ms
29,876 KB
testcase_03 AC 133 ms
29,816 KB
testcase_04 AC 130 ms
29,788 KB
testcase_05 AC 130 ms
29,836 KB
testcase_06 AC 129 ms
29,896 KB
testcase_07 AC 131 ms
29,900 KB
testcase_08 AC 131 ms
29,736 KB
testcase_09 AC 132 ms
29,740 KB
testcase_10 AC 132 ms
29,788 KB
testcase_11 AC 133 ms
29,836 KB
testcase_12 AC 131 ms
29,712 KB
testcase_13 AC 138 ms
30,340 KB
testcase_14 AC 136 ms
30,136 KB
testcase_15 AC 155 ms
33,140 KB
testcase_16 AC 167 ms
34,028 KB
testcase_17 AC 669 ms
88,880 KB
testcase_18 AC 1,164 ms
152,780 KB
testcase_19 AC 1,163 ms
152,616 KB
testcase_20 AC 1,175 ms
152,840 KB
testcase_21 AC 1,177 ms
152,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

# %%
H, W = map(int, readline().split())
S = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]

# %%
INF = 10 ** 8
dist = np.zeros((H + 2, W + 2), np.int32)
dist[1:-1, 1:-1] += INF * (S == b'#')

# %%
for _ in range(4):
    dist = dist[::-1].T
    for n in range(1, dist.shape[0]):
        np.minimum(dist[n], dist[n - 1] + 1, out=dist[n])
        np.minimum(dist[n, 1:], dist[n - 1, :-1] + 1, out=dist[n, 1:])

# %%
print(dist.max())
0