結果

問題 No.790 ちきんの括弧並べ
ユーザー MayimgMayimg
提出日時 2019-02-22 08:06:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 735 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 199,788 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 04:49:48
合計ジャッジ時間 3,831 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < (1 << 2 * n); i++) {
		int c = 0, cc = 0;
		for (int j = 0; j < 2 * n; j++) {
			c += (i >> j) & 1 ? 1 : -1;
			cc = min(c, cc);
			if (cc < 0) break;
		}
		ans += cc == 0 && c == 0;
	}
	cout << ans << endl;
	return 0;	
}
0