結果
問題 |
No.790 ちきんの括弧並べ
|
ユーザー |
|
提出日時 | 2019-07-24 10:26:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 2,465 ms |
コンパイル使用メモリ | 169,508 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-06-27 20:11:53 |
合計ジャッジ時間 | 5,693 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 8 TLE * 1 -- * 1 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; bool isOK(string s){ bool ret = true; int cnt = 0; rep(i, s.size()){ if(s[i] == '(') cnt++; else cnt--; if(cnt < 0) ret = false; } if(cnt != 0) ret = false; return ret; } int main(){ int n; cin >> n; ll ans = 0; for(int bit = 0; bit < (1<<(2*n)); bit++){ string s = ""; int cnt = 0; for(int i=0; i<2*n; i++){ if(bit & (1<<i)) s += "("; else{ s += ")"; cnt++; } } if(cnt != n) continue; ans += isOK(s); } cout << ans << endl; return 0; }