結果
| 問題 |
No.790 ちきんの括弧並べ
|
| ユーザー |
Hoi_koro
|
| 提出日時 | 2019-02-20 22:05:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 2,000 ms |
| コンパイル使用メモリ | 170,580 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 18:48:24 |
| 合計ジャッジ時間 | 2,638 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision
#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;
struct Problem {
int n;
vector<vector<LL>> dp;
Problem(LL n) : n(n), dp(2 * n + 1, vector<LL>(2 * n + 1)){};
void solve() {
dp[0][0] = 1;
for (int i = 1; i <= 2 * n; ++i) {
for (int j = 0; j <= i; ++j) {
if (j * 2 < i) continue;
dp[i][j] += dp[i - 1][j];
if (j > 0) dp[i][j] += dp[i - 1][j - 1];
}
}
cout << dp[2 * n][n] << endl;
}
};
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
long long n = 0;
cin >> n;
Problem p(n);
p.solve();
return 0;
}
Hoi_koro