結果

問題 No.640 76本のトロンボーン
ユーザー H3PO4H3PO4
提出日時 2020-10-25 10:07:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 29,816 KB
最終ジャッジ日時 2023-09-28 22:26:34
合計ジャッジ時間 5,747 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
29,704 KB
testcase_01 AC 136 ms
29,628 KB
testcase_02 AC 133 ms
29,612 KB
testcase_03 AC 133 ms
29,580 KB
testcase_04 AC 134 ms
29,668 KB
testcase_05 AC 142 ms
29,632 KB
testcase_06 AC 144 ms
29,728 KB
testcase_07 AC 137 ms
29,688 KB
testcase_08 AC 142 ms
29,648 KB
testcase_09 AC 135 ms
29,680 KB
testcase_10 AC 134 ms
29,612 KB
testcase_11 AC 140 ms
29,736 KB
testcase_12 AC 136 ms
29,700 KB
testcase_13 AC 130 ms
29,692 KB
testcase_14 AC 132 ms
29,816 KB
testcase_15 AC 133 ms
29,664 KB
testcase_16 AC 132 ms
29,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())
S = np.array([[s == '.' for s in input()] for _ in range(N)])


def solve(S):
    """左詰め横並べ"""
    left = S[:, 0].copy()
    right = S[:, -1].copy()
    res = 0
    for i in range(N):
        if np.all(S[i, 1:-1]):
            if S[i, 0]:
                res += 1
                left[i] = False
            elif S[i, -1]:
                res += 1
                right[i] = False
    if np.all(left[1:-1]) and (left[0] or left[-1]):
        res += 1
    if np.all(right[1:-1]) and (right[0] or right[-1]):
        res += 1

    return res


ans = 0
# ぐるっと一周パターン
if np.all(S[0, :]) and np.all(S[:, 0]) and np.all(S[-1, :]) and np.all(S[:, -1]):
    ans = 4

for i in range(4):
    ans = max(ans, solve(S))
    # 回す
    S = np.fliplr(S.T)
print(ans)
0