結果

問題 No.402 最も海から遠い場所
ユーザー rpy3cpprpy3cpp
提出日時 2016-07-22 23:23:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,470 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 156,660 KB
最終ジャッジ日時 2024-04-24 06:07:35
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 39 ms
53,628 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 AC 477 ms
155,992 KB
testcase_20 AC 622 ms
156,268 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = [[-1] * W for i in range(H)]
    for h in range(H):
        d = 0
        Sh = S[h]
        disth = dist[h]
        for w, c in enumerate(Sh):
            if c == '#':
                d += 1
                if disth[w] == -1 or disth[w] > d:
                    disth[w] = d
            else:
                d = 0
    for h in range(H):
        d = 0
        Sh = S[h]
        disth = dist[h]
        for w in range(W-1, -1, -1):
            c = Sh[w]
            if c == '#':
                d += 1
                if disth[w] == -1 or disth[w] > d:
                    disth[w] = d
            else:
                d = 0
    for w in range(W):
        d = 0
        Sw = S[w]
        distw = dist[w]
        for h, c in enumerate(Sw):
            if c == '#':
                d += 1
                if distw[h] == -1 or distw[h] > d:
                    distw[h] = d
            else:
                d = 0
    for w in range(W):
        d = 0
        Sw = S[w]
        distw = dist[w]
        for h in range(H-1, -1, -1):
            if c == '#':
                d += 1
                if distw[h] == -1 or distw[h] > d:
                    distw[h] = d
            else:
                d = 0
    maxd = 0
    for row in dist:
        maxd = max(maxd, max(row))
    return maxd

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