結果

問題 No.790 ちきんの括弧並べ
ユーザー hstn
提出日時 2020-12-22 08:23:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 17,696 KB
最終ジャッジ日時 2024-09-21 13:47:00
合計ジャッジ時間 5,320 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other WA * 7 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

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