結果

問題 No.790 ちきんの括弧並べ
ユーザー hstnhstn
提出日時 2020-12-22 08:23:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,976 KB
実行使用メモリ 14,588 KB
最終ジャッジ日時 2023-10-21 12:29:18
合計ジャッジ時間 5,381 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())*2

def check (l:list):
    c0 = 0
    c1 = 0
    for x in l:
        if x == 0:
            c0 += 1
        else: # x == 1:
            c1 += 1
            if c1 < c0:
                pass
            elif c1 == c0:
                c0 = 0
                c1 = 0
                continue
            else: # c0 < c1:
                return False
    else:
        return True

ans = 0
for i in range(2**n):
    bit = [0]*n
    for j in range(n):
        if ((i>>j)&1):
            bit[n-1-j] = 1

    # 処理
    if not bit.count(0) == bit.count(1):
        continue

    if check (bit):
        print (bit)
        ans += 1

print (ans)
0