結果

問題 No.790 ちきんの括弧並べ
ユーザー hstnhstn
提出日時 2020-12-22 08:15:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 635 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,000 KB
実行使用メモリ 10,088 KB
最終ジャッジ日時 2023-10-21 12:29:07
合計ジャッジ時間 6,174 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,088 KB
testcase_01 AC 31 ms
10,088 KB
testcase_02 AC 32 ms
10,088 KB
testcase_03 AC 43 ms
10,088 KB
testcase_04 AC 88 ms
10,088 KB
testcase_05 AC 305 ms
10,088 KB
testcase_06 AC 1,214 ms
10,088 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

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