結果

問題 No.790 ちきんの括弧並べ
ユーザー siman
提出日時 2021-06-18 18:56:25
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 782 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 1,835 ms
コンパイル使用メモリ 140,612 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 16:38:01
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  N *= 2;

  for (int mask = 0; mask < (1 << N); ++mask) {
    int l = 0;
    int r = 0;
    bool ok = false;

    for (int i = 0; i < N; ++i) {
      if (mask >> i & 1) {
        ++l;
      } else {
        ++r;
      }
      if (l < r) {
        ok = true;
        break;
      }
    }
    if (l == r && not ok) ++ans;
  }

  cout << ans << endl;

  return 0;
}
0