結果
問題 |
No.790 ちきんの括弧並べ
|
ユーザー |
|
提出日時 | 2023-09-07 20:38:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 415 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 82,316 KB |
実行使用メモリ | 75,576 KB |
最終ジャッジ日時 | 2024-06-25 14:21:22 |
合計ジャッジ時間 | 1,746 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
# [開き括弧の個数, 今何番目] N = int(input()) stack = [] stack.append([1, 1]) ans = 0 M = 2 * N while stack: opened, cnt = stack.pop() if cnt == M: if opened == 0: ans += 1 continue if opened - 1 >= 0: stack.append([opened - 1, cnt + 1]) if M - (cnt + 1) >= opened + 1: stack.append([opened + 1, cnt + 1]) print(ans)