結果

問題 No.790 ちきんの括弧並べ
ユーザー Mister
提出日時 2020-04-18 01:25:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 74,476 KB
最終ジャッジ日時 2025-01-09 21:02:16
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int n;
    std::cin >> n;

    auto comb = vec(n * 2 + 1, vec(n * 2 + 1, 0));
    comb[0][0] = 1;
    for (int x = 0; x < n * 2; ++x) {
        for (int y = 0; y <= x; ++y) {
            comb[x + 1][y] += comb[x][y];
            comb[x + 1][y + 1] += comb[x][y];
        }
    }

    std::cout << comb[n * 2][n] / (n + 1) << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0