結果

問題 No.790 ちきんの括弧並べ
ユーザー pasoconhoshii
提出日時 2019-02-20 22:22:25
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,582 ms / 2,000 ms
コード長 580 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 647 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 364,264 KB
最終ジャッジ日時 2026-05-08 03:01:00
合計ジャッジ時間 4,602 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())

s = [ 0 for _ in range(N+1)]
s[0] = set([""])
for i in range(1,N+1):
    lst = []
    for ss in s[i-1]:
        lst.append("(" + ss +")")
        lst.append("()"+ss)
        lst.append(ss+"()")

    for p in range(1,i+1): # 0 to N (i)
        if s[i-p] != 0:
            for ss2 in s[i-p]: # 0 to 
                if s[p] != 0:
                    for ss3 in s[p]:
                        lst.append( ss2 + ss3 ) 
                        lst.append( ss3 + ss2 ) 

    s[i] = set(lst)

print(len(s[N]))
# print(s[N])
    
0