結果

問題 No.3141 Balancing with X=>O Flip
コンテスト
ユーザー it_is_a_pity_
提出日時 2025-05-16 21:25:26
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 632 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,765 ms
コンパイル使用メモリ 273,920 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-10 19:49:32
合計ジャッジ時間 4,590 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(v) v.begin(),v.end()
const ll INF = (ll)2e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    string S;
    cin >> N >> S;
    if(N%2==1){
        cout << "No" << endl;
        return 0;
    }
    ll cnt = 0;
    rep(i,N){
        if(S[i]=='('){
            cnt++;
        }
    }
    if(cnt!=N-cnt){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}
0