結果

問題 No.3142 Balancing with O=>X Flip
ユーザー Cecil
提出日時 2025-05-16 23:40:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 195,696 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-16 23:54:34
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    if (N%2==1){
        cout << "No" << endl;
        return 0;
    }
    vector<char> stack;
    for (int i=0; i<N; i++){
        if (stack.size()>0 && stack.back()=='(' && S[i]==')'){
            stack.pop_back();
        } else {
            stack.push_back(S[i]);
        }
    }
    if (stack.empty()){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
0