結果

問題 No.790 ちきんの括弧並べ
ユーザー tails1434tails1434
提出日時 2020-01-09 22:00:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 541 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-05-02 14:31:37
合計ジャッジ時間 4,644 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,256 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 35 ms
10,752 KB
testcase_05 AC 62 ms
10,752 KB
testcase_06 AC 170 ms
10,752 KB
testcase_07 AC 600 ms
10,752 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    cnt = 0
    for i in range(1<<(N * 2)):
        bin_num = bin(i)[2:]
        if bin_num.count('1') != N:
            continue 
        left = 0
        right = 0
        flag = True
        for j in range(N * 2):
            if (i >> j) & 1:
                left += 1
            else:
                right += 1

            if right > left:
                flag = False
                break
        if flag and right == left:
            cnt += 1

    print(cnt)

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