結果

問題 No.402 最も海から遠い場所
ユーザー maspymaspy
提出日時 2020-03-12 21:38:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,835 ms / 3,000 ms
コード長 601 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 166,844 KB
最終ジャッジ日時 2024-04-29 22:57:14
合計ジャッジ時間 20,624 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 543 ms
43,840 KB
testcase_01 AC 550 ms
44,104 KB
testcase_02 AC 549 ms
43,968 KB
testcase_03 AC 536 ms
43,848 KB
testcase_04 AC 530 ms
43,976 KB
testcase_05 AC 535 ms
43,708 KB
testcase_06 AC 547 ms
43,592 KB
testcase_07 AC 535 ms
43,584 KB
testcase_08 AC 539 ms
43,972 KB
testcase_09 AC 540 ms
43,724 KB
testcase_10 AC 534 ms
43,968 KB
testcase_11 AC 552 ms
43,972 KB
testcase_12 AC 568 ms
43,972 KB
testcase_13 AC 594 ms
43,968 KB
testcase_14 AC 561 ms
43,972 KB
testcase_15 AC 559 ms
45,640 KB
testcase_16 AC 574 ms
46,268 KB
testcase_17 AC 1,172 ms
103,108 KB
testcase_18 AC 1,835 ms
166,600 KB
testcase_19 AC 1,826 ms
166,844 KB
testcase_20 AC 1,815 ms
166,840 KB
testcase_21 AC 1,808 ms
166,420 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