結果

問題 No.790 ちきんの括弧並べ
ユーザー Mayimg
提出日時 2019-02-22 08:06:24
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 458 ms / 2,000 ms
+ 926µs
コード長 405 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,060 ms
コンパイル使用メモリ 210,408 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-10-11 15:34:25
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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