結果

問題 No.402 最も海から遠い場所
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-07-26 13:58:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,683 ms / 3,000 ms
コード長 730 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 166,016 KB
最終ジャッジ日時 2024-04-24 09:33:09
合計ジャッジ時間 7,760 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,352 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 55 ms
63,744 KB
testcase_03 AC 40 ms
52,480 KB
testcase_04 AC 36 ms
52,608 KB
testcase_05 AC 35 ms
52,096 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 35 ms
52,224 KB
testcase_08 AC 35 ms
52,224 KB
testcase_09 AC 37 ms
52,096 KB
testcase_10 AC 37 ms
52,096 KB
testcase_11 AC 49 ms
62,720 KB
testcase_12 AC 39 ms
53,376 KB
testcase_13 AC 77 ms
76,800 KB
testcase_14 AC 81 ms
76,288 KB
testcase_15 AC 112 ms
78,592 KB
testcase_16 AC 147 ms
80,000 KB
testcase_17 AC 637 ms
115,584 KB
testcase_18 AC 1,683 ms
166,016 KB
testcase_19 AC 539 ms
165,632 KB
testcase_20 AC 1,639 ms
165,888 KB
testcase_21 AC 1,006 ms
166,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import array
import itertools


def compute(height, width, is_sea):
    square_size = 0
    dp = [array.array("L", (0 for _ in range(width + 2)))
          for _ in range(height + 2)]
    for r, c in itertools.product(range(1, height + 1), range(1, width + 1)):
        if not is_sea[r - 1][c - 1]:
            dp[r][c] = min(dp[r - 1][c - 1], dp[r - 1][c], dp[r][c - 1]) + 1
            square_size = max(square_size, dp[r][c])
    return (square_size + 1) // 2


def main():
    height, width = map(int, input().split())
    is_sea = [array.array("B", map(lambda x: x == ".", input()))
              for _ in range(height)]
    print(compute(height, width, is_sea))


if __name__ == '__main__':
    main()
0