結果

問題 No.402 最も海から遠い場所
ユーザー rpy3cpprpy3cpp
提出日時 2016-07-24 00:21:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 799 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 49,664 KB
最終ジャッジ日時 2024-04-24 08:15:07
合計ジャッジ時間 7,282 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
16,128 KB
testcase_01 AC 25 ms
10,624 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 28 ms
10,752 KB
testcase_07 AC 28 ms
10,624 KB
testcase_08 AC 25 ms
10,624 KB
testcase_09 AC 25 ms
10,624 KB
testcase_10 AC 26 ms
10,624 KB
testcase_11 AC 25 ms
10,752 KB
testcase_12 AC 25 ms
10,752 KB
testcase_13 AC 36 ms
11,136 KB
testcase_14 AC 33 ms
10,880 KB
testcase_15 AC 88 ms
12,672 KB
testcase_16 AC 155 ms
13,696 KB
testcase_17 AC 1,320 ms
49,664 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    H, W = map(int, input().split())
    S = [input() for i in range(H)]
    return H, W, S

def solve(H, W, S):
    dist = [[float('inf')] * W for i in range(H)]
    for w in range(W):
        if S[0][w] == '#':
            dist[0][w] = 1
        else:
            dist[0][w] = 0
    for h in range(1, H):
        Sh = S[h]
        disth = dist[h]
        disthm = dist[h - 1]
        for w, c in enumerate(Sh):
            if c == '#':
                if w:
                    disth[w] = min(disth[w - 1], disthm[w - 1], disthm[w]) + 1
                else:
                    disth[w] = 1
            else:
                disth[w] = 0
    maxd = 0
    for row in dist:
        maxd = max(maxd, max(row))
    return (maxd + 1) // 2

H, W, S = read_data()
print(solve(H, W, S))
0