結果

問題 No.402 最も海から遠い場所
ユーザー rpy3cpprpy3cpp
提出日時 2016-07-24 00:22:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 510 ms / 3,000 ms
コード長 799 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 226,560 KB
最終ジャッジ日時 2024-04-24 08:15:12
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,096 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 50 ms
59,648 KB
testcase_03 AC 41 ms
51,712 KB
testcase_04 AC 41 ms
52,096 KB
testcase_05 AC 41 ms
52,224 KB
testcase_06 AC 41 ms
52,096 KB
testcase_07 AC 41 ms
52,096 KB
testcase_08 AC 40 ms
52,224 KB
testcase_09 AC 40 ms
52,224 KB
testcase_10 AC 40 ms
51,840 KB
testcase_11 AC 46 ms
58,752 KB
testcase_12 AC 42 ms
52,736 KB
testcase_13 AC 61 ms
66,176 KB
testcase_14 AC 68 ms
66,688 KB
testcase_15 AC 90 ms
77,952 KB
testcase_16 AC 95 ms
78,848 KB
testcase_17 AC 303 ms
148,480 KB
testcase_18 AC 507 ms
226,560 KB
testcase_19 AC 394 ms
223,488 KB
testcase_20 AC 510 ms
226,304 KB
testcase_21 AC 435 ms
222,848 KB
権限があれば一括ダウンロードができます

ソースコード

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