結果

問題 No.790 ちきんの括弧並べ
ユーザー silopy
提出日時 2019-06-29 01:30:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 65,644 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-02 05:20:39
合計ジャッジ時間 1,296 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
using lint=int64_t;

int N;
int N2;
int ans=0;
int ocnt;
int ccnt;

void dfs(int d)
{
	if(ocnt>N || ccnt>N)
		return;
	if(ccnt>ocnt)
		return;
	
	if(d==N2)
	{
		ans++;
		return;
	}

	ocnt++;
	dfs(d+1);
	ocnt--;
	ccnt++;
	dfs(d+1);
	ccnt--;
	return;
}

int main()
{
	cin >> N;
	N2=2*N;
	dfs(0);
	cout << ans << endl;
	return 0;
}
0