結果

問題 No.3141 Balancing with X=>O Flip
ユーザー Leal-0
提出日時 2025-05-16 21:25:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,822 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 207,968 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-17 03:13:17
合計ジャッジ時間 2,720 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN

#include __FILE__

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int cntl=0,cntr=0;
    rep(i,n) {
        if(s[i]=='(') cntl++;
        else cntr++;
    }
    cout<<(n%2==0 && cntl==cntr ? "Yes":"No")<<nl;
}

/////// library zone ///////
#else
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define irep(i,r,l) for(ll i=r;i>=l;i--)
#define srep(i,l,r) for(ll i=l;i<=r;i++)
using ll = long long;
using ld = long double;
const ll mod=998244353;
#define vout(v) for(auto i :v) cout<<i<<" ";
#define INF 9223300000000000000ll
#define Winf 5e12
#define nl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vl vector<ll>
#define vc vector<char>
map<char,ll> mp;
map<ll,char> ivmp;

template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}

void no() { cout<<"No"<<nl;}
void yes() { cout<<"Yes"<<nl;}
void yn(bool a) {
    cout<<(a ? "Yes":"No")<<nl;
}

ll sum(vector<ll>& a) {
    ll ans=0;
    for(auto i:a) ans+=i;
    return ans;
}




ll modpow(ll fl, ll po, ll mode) {  // mode: 0=modなし, 1=modあり
    ll ret=1;
    if (mode) {
        while (po>0) {
            if (po&1) ret=(ret*fl)%mod;
            fl=(fl*fl)%mod;
            po>>=1;
        }
    } else {
        while (po>0) {
            if(po&1) ret*=fl;
            fl*=fl;
            po>>=1;
        }
    }
    return ret;
}

ll hashed(string &s) {
    ll n=s.size();
    ll res=0;
    rep(i,n) {
        res+=(mp[s[i]]*modpow(3,i,1));
    }
    return res;
}

string unhash(ll h, ll n){
    string s(n,'?');
    rep(i,n) {
        ll d=h%3;
        s[i]=ivmp[d];
        h/=3;
    }
    return s;
}

#endif
0