結果

問題 No.3099 Parentheses Decomposition
ユーザー noya2
提出日時 2025-04-07 02:24:48
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 6,688 ms
コンパイル使用メモリ 260,932 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-07 02:24:57
合計ジャッジ時間 7,645 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"testlib.h"

using ll = long long;
const ll Nmin = 2;
const ll Nmax = 500'000;

int main(){
    registerValidation();
    ll N = inf.readLong(Nmin, Nmax);
    inf.readEoln();
    std::string S = inf.readToken();
    inf.readEoln();
    inf.readEof();

    inf.ensuref(N % 2 == 0, "N is even");
    bool typeA = [&]{
        for (ll i = 0; i < N/2; i++){
            if (S[i] == '(') continue;
            return false;
        }
        for (ll i = N/2; i < N; i++){
            if (S[i] == ')') continue;
            return false;
        }
        return true;
    }();
    bool typeB = [&]{
        for (ll i = 0; i < N; i++){
            if (i % 2 == 0){
                if (S[i] == '(') continue;
                return false;
            }
            else {
                if (S[i] == ')') continue;
                return false;
            }
        }
        return true;
    }();
    inf.ensuref(typeA || typeB, "S is type A or type B");
}
0