結果

問題 No.790 ちきんの括弧並べ
ユーザー satou_a_mansatou_a_man
提出日時 2019-02-21 00:46:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 159,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 15:28:09
合計ジャッジ時間 2,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll memo[13];
ll c(ll n) {
  if(memo[n]!=-1)
    return memo[n];
  if(n==0)
    return memo[n]=1;
  ll ret=0;
  rep(k,n) {
    ret+=c(k)*c(n-k-1);
  }
  return memo[n]=ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  memset(memo,-1,sizeof(memo));
  int n;
  cin>>n;
  cout << c(n) << endl;
  return 0;
}
0