結果

問題 No.790 ちきんの括弧並べ
ユーザー Y17Y17
提出日時 2019-03-02 16:14:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 142,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 16:55:28
合計ジャッジ時間 1,834 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n;
long long dfs(int l, int r){
    if(l == 0 && r == 0){
        return 1;
    }

    long long ans = 0;
    if(0 < l){
        ans += dfs(l-1, r);
    }
    if(l < r){
        ans += dfs(l, r-1);
    }

    return ans;
}

int main(){
    cin >> n;
    cout << dfs(n, n) << endl;
    return 0;
}
0