結果

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

ソースコード

diff #

n = int(input())*2

def check (l:list):
    if not l.count(0) == l.count(1):
        return False

    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 check (bit):
        ans += 1

print (ans)
0