結果

問題 No.2143 Only One Bracket
コンテスト
ユーザー tau0529
提出日時 2026-07-19 03:15:09
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 406µs
コード長 9,883 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,259 ms
コンパイル使用メモリ 345,880 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-19 03:15:13
合計ジャッジ時間 3,269 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//.at(i)を[i]と書いても警告が出るように
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
using namespace std;


//int64_t
using lint = int64_t;

//long double
using ld = long double;

//ベクター
template<typename T> using vc = vector<T>; //1次元リスト
template<typename T> using vv = vector<vector<T>>; //2次元リスト
template<typename T> using vvv = vector<vector<vector<T>>>; //3次元リスト
template<typename T> using vvvv = vector<vector<vector<vector<T>>>>; //4次元リスト

//ペア
using pll = pair<int64_t, int64_t>;

//プライオリティーキュー
template<typename T> using pq = priority_queue<T, vector<T>>; // 大きい順
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>; // 小さい順

#define pb push_back
#define mp make_pair
#define fi first
#define se second

//all マクロ
#define all(v) (v).begin(), (v).end()

//ループマクロ
#define     re(n)       for (int64_t r_= 0;            r_<  int64_t(n);r_++)
#define    rep(i, n)    for (int64_t i = 0;            i <  int64_t(n); i++)
#define   repp(i, n)    for (int64_t i = 0;            i <= int64_t(n); i++)
#define   rrep(i, a, b) for (int64_t i = int64_t(a);   i <  int64_t(b); i++)
#define  rrepp(i, a, b) for (int64_t i = int64_t(a);   i <= int64_t(b); i++)
#define   reep(i, n)    for (int64_t i = int64_t(n)-1; i >= 0;          i--)
#define  reepp(i, n)    for (int64_t i = int64_t(n);   i >= 0;          i--)
#define  rreep(i, a, b) for (int64_t i = int64_t(b)-1; i >= int64_t(a); i--)
#define rreepp(i, a, b) for (int64_t i = int64_t(b);   i >= int64_t(a); i--)

//sizeをint64_t型に
#define sz(x) ((int64_t)x.size())

//next_permutation
#define next_p(v) next_permutation((v).begin(), (v).end())


//無限
const int64_t inf = 1001001001;
const int64_t INF = 4004004004004004004LL;

//モッド
const int64_t MOD = 998244353;
//const int64_t MOD = 1000000007;

//パイ
const long double pi = 3.141592653589793238L;

//ネイピア数
const long double napier = 2.7182818284590452353L;

//移動
static constexpr int64_t dh[] = {0, -1, 0, 1, -1, -1, 1, 1};
static constexpr int64_t dw[] = {1, 0, -1, 0, 1, -1, -1, 1};



//cin cout オーバーロード
//vector
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T & in : v) is >> in;
    return is;
}
template <typename T>
ostream &operator<<(ostream & os, const vector<T> &v) {
    for (int64_t i = 0; i < (int64_t)v.size(); i++) {
        os << v[i] << (i + 1 != (int64_t)v.size() ? " " : "");
    }
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
    for (int64_t i = 0; i < (int64_t)v.size(); i++) {
        os << v[i] << endl;
    }
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<vector<T>>> &v) {
    for (int64_t i = 0; i < (int64_t)v.size(); i++) {
        os << "i = " << i << endl;
        os << v[i];
    }
    return os;
}

//pair
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}
template <typename T1, typename T2>
ostream &operator<<(ostream & os, const pair<T1, T2> & p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}


//vector複数行受け取り
template <typename T1, typename T2>
void vcin(vector<T1> &u, vector<T2> &v) {
    if (u.size() != v.size()) {
        cerr << "vcinエラー サイズが異なります" << endl;
        assert(false);
        return;
    }
    for (int64_t i = 0; i < (int64_t)u.size(); i++) {
        cin >> u[i] >> v[i];
    }
    return;
}
template <typename T1, typename T2, typename T3>
void vcin(vector<T1> &u, vector<T2> &v, vector<T3> &w) {
    if (u.size() != v.size() || v.size() != w.size()) {
        cerr << "vcinエラー サイズが異なります" << endl;
        assert(false);
        return;
    }
    for (int64_t i = 0; i < (int64_t)u.size(); i++) {
        cin >> u[i] >> v[i] >> w[i];
    }
    return;
}


//Yes No出力
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

void YN (bool b) {
    if (b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}
void yn (bool b) {
    if (b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}



// 値の更新
template<typename T1, typename T2>
bool chmax(T1 &x, const T2 &y) {
    bool compare = x < y;
    if (compare) x = y;
    return compare;
}
template<typename T1, typename T2>
bool chmin(T1 &x, const T2 &y) {
    bool compare = x > y;
    if (compare) x = y;
    return compare;
}

//経過時間
long double Time () {
    return 1.0 * (clock()) / CLOCKS_PER_SEC;
}


//小さい順
template<typename T>
void Vsort (vector<T> &v) {
    sort(v.begin(), v.end());
    return;
}
//大きい順
template<typename T>
void Vsortg (vector<T> &v) {
    sort(v.rbegin(), v.rend());
    return;
}

//リバース
template<typename T>
void Vreverse (vector<T> &v) {
    reverse(v.begin(), v.end());
    return;
}

//重複の削除
template<typename T>
void Vunique (vector<T> &v) {
    #ifndef ONLINE_JUDGE
    static bool w = false;
    if (!w) { cerr << "Vuniqueでは必ずソートされてますか?" << endl; w = true; }
    #endif
    v.erase(unique(v.begin(), v.end()), v.end());
    return;
}

//上下反転
template<typename T>
void UDflip (vector<vector<T>> &v) {
    reverse(v.begin(), v.end());
    return;
}

//左右反転
template<typename T>
void LRflip (vector<vector<T>> &v) {
    for (auto &x : v) {
        reverse(x.begin(), x.end());
    }
    return;
}

//リストの移動
template<typename T>
void Vrotate (vector<T> &v, int64_t n) {
    if (v.empty()) return;
    n %= (int64_t)v.size();
    rotate(v.begin(), v.begin() + n, v.end());
    return;
}

//右回転
template<typename T>
void VVrotate (vector<vector<T>> &v) {
    int64_t H = v[0].size();
    int64_t W = v.size();
    vector<vector<T>> L(H, vector<T>(W));
    for (int64_t i = 0; i < W; i++) {
        for (int64_t j = 0; j < H; j++) {
            L[j][W - i - 1] = v[i][j];
        }
    }
    v = L;
    return;
}

//左回転
template<typename T>
void VVrotateg (vector<vector<T>> &v) {
    int64_t H = v[0].size();
    int64_t W = v.size();
    vector<vector<T>> L(H, vector<T>(W));
    for (int64_t i = 0; i < W; i++) {
        for (int64_t j = 0; j < H; j++) {
            L[H - j - 1][i] = v[i][j];
        }
    }
    v = L;
    return;
}


//2次元距離
template<typename T>
long double distan (T x1, T y1, T x2, T y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
//2次元距離の2乗
template<typename T>
T distan2 (T x1, T y1, T x2, T y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

//範囲内チェック
#define in_grid(h, w, H, W) if (!(0 <= h && 0 <= w && h < H && w < W)) continue;


//nPr
int64_t nPr (int64_t n, int64_t r) {
    int64_t Ans = 1;
    for (int64_t i = 0; i < r; i++) {
        Ans *= n - i;
    }
    return Ans;
}

//nCr
vector<vector<int64_t>> nCr_memo;
int64_t nCr (int64_t n, int64_t r) {
    if (n < r) {
        cerr << "Error nCrのrがnより大きいです" << endl;
        assert(false);
        return 0;
    }
    for (int64_t i = (int64_t)nCr_memo.size(); i <= n; i++) {
        nCr_memo.push_back(vector<int64_t>(i + 1, 1));
        for (int64_t j = 1; j < i; j++) {
            nCr_memo[i][j] = nCr_memo[i - 1][j - 1] + nCr_memo[i - 1][j];
        }
    }
    return nCr_memo[n][r];
}

//累乗
int64_t power (int64_t a, int64_t b) {
    int64_t Ans = 1;
    while (b > 0) {
        if (b & 1) Ans *= a;
        a *= a;
        b >>= 1;
    }
    return Ans;
}

//階乗
int64_t factorial(int64_t n) {
    int64_t Ans = 1;
    for (int64_t i = 1; i <= n; i++) Ans *= i;
    return Ans;
}

//数値のN桁目
int64_t digit(int64_t x, int64_t k) {
    while (k--) x /= 10;
    return x % 10;
}


//!MOD関連の関数 ここをベースに使用することもあるので 消さないこと

//MOD累乗
int64_t Mpower(int64_t a, int64_t b, int64_t mod) {
    int64_t Ans = 1;
    a %= mod;
    while (b > 0) {
        if (b & 1) Ans = (Ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return Ans;
}

//int128のMOD累乗
__int128_t MPOWER(__int128_t a, __int128_t b, __int128_t mod) {
    __int128_t Ans = 1;
    a %= mod;
    while (b > 0) {
        if (b & 1) Ans = (Ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return Ans;
}


//ミラーラビンの素数判定 int128MOD累乗
bool is_prime(int64_t N) {
    if (N <= 1) return false;
    if (N == 2) return true;
    if (N % 2 == 0) return false;
    vector<int64_t> L = {2, 7, 61};
    if (N >= 4759123141LL) L = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
    int64_t s = 0, d = N - 1;
    while (d % 2 == 0) {
        s++;
        d >>= 1;
    }
    for (auto x : L) {
        if (N <= x) return true;
        int64_t t, p = MPOWER(x, d, N);
        if (p != 1) {
            for (t = 0; t < s; t++) {
                if (p == N - 1) break;
                p = __int128_t(p) * p % N;
            }
            if (t == s) return false;
        }
    }
    return true;
}

//!####################################################################################################

void solve () {
    lint N; cin >> N;
    vc<string> L(N);
    L[0] = string(N - 1, '(');
    rep (i, N-1) {
        string s;
        re (N - i - 1) s += ')';
        re (N - i - 2) s += '(';
        L[i+1] = s;
    }
    cout << L << endl;
    return;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
    lint T = 1;
    //cin >> T;
    re (T) solve();
    cerr << endl << Time() << endl;
}

0