結果

問題 No.402 最も海から遠い場所
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-07-26 13:58:59
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,795 ms / 3,000 ms
コード長 730 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 166,928 KB
最終ジャッジ日時 2023-08-06 13:54:16
合計ジャッジ時間 9,190 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,504 KB
testcase_01 AC 75 ms
71,416 KB
testcase_02 AC 87 ms
76,516 KB
testcase_03 AC 76 ms
71,600 KB
testcase_04 AC 76 ms
71,508 KB
testcase_05 AC 74 ms
71,600 KB
testcase_06 AC 74 ms
71,764 KB
testcase_07 AC 72 ms
71,260 KB
testcase_08 AC 71 ms
71,556 KB
testcase_09 AC 72 ms
71,636 KB
testcase_10 AC 73 ms
71,540 KB
testcase_11 AC 82 ms
76,432 KB
testcase_12 AC 72 ms
71,624 KB
testcase_13 AC 103 ms
77,628 KB
testcase_14 AC 106 ms
77,316 KB
testcase_15 AC 143 ms
79,640 KB
testcase_16 AC 177 ms
80,644 KB
testcase_17 AC 716 ms
116,916 KB
testcase_18 AC 1,795 ms
166,796 KB
testcase_19 AC 612 ms
166,692 KB
testcase_20 AC 1,752 ms
166,476 KB
testcase_21 AC 1,093 ms
166,928 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