結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー wtbk wtbk
提出日時 2026-04-17 21:36:29
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 3,006 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,990 ms
コンパイル使用メモリ 229,492 KB
実行使用メモリ 48,108 KB
最終ジャッジ日時 2026-04-17 21:37:30
合計ジャッジ時間 42,223 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound


#include <bitset>  // bitset
#include <cctype>  // isupper, islower, isdigit, toupper, tolower
#include <cmath>   // cmathライブラリをインクルード
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <iomanip>
#include <iostream>      // cout, endl, cin
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Yout cout << "Yes" << '\n'
#define Nout cout << "No" << '\n'
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
// #define _LIBCPP_DEBUG 0と書く必要があります。
const ll mod = 998244353;
const ll mod2 = (long long)1000000007;
const ll INF = (long long)2e18;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
//  const vector<int> dx = {1, 1, 1, 0, -1, -1, -1, 0};
//  const vector<int> dy = {1, 0, -1, -1, -1, 0, 1, 1};
// const vector<int> dx = {1, -1, 1, -1};
// const vector<int> dy = {1, 1, -1, -1};

template <class T> void li(T a) {
  for (auto i : a) {
    cout << i << ' ';
  }
  cout << endl;
}

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

bool ch(ll l, ll r, ll x) { return l <= x and x < r; }

bool chch(ll h, ll w, ll x, ll y) { return ch(0, h, x) and ch(0, w, y); }




void solve(){
	
	ll q;cin >> q;
	vector<vector<ll>> a(1,vector<ll>(3,0));
	vector<bool> sm(1,true);
	vector<bool> d(1,true);
	string s=" ";
	rep(i,q){
		ll id;cin >> id;
		
		if(id==1){
			char c;cin >> c;
			
			bool f=true;
			auto nex=a.back();
			if(c=='('){
				nex[0]++;
				
			}
			else if(c==')'){
				nex[2]++;
				if(s.back()=='('){
					f=false;
				}
			}
			else{
				nex[1]++;
				if(s.back()=='|'){
					f=false;
				}
			}
			a.pb(nex);
			s+=c;
			if(nex[1]>nex[0] or nex[2]>nex[0] or nex[2]>nex[1]){
				f=false;
			}
			
			
			sm.pb(f && sm.back());
			d.pb(f);
		}
		else{
			//sm.pop_back();
			a.pop_back();
			sm.pop_back();d.pop_back();
		}
		/*
		rep(j,3){
		rep(k,a.size()){
			cout << a[k][j] << ' ';
		}cout << endl;
		}
		li(d);
		li(sm);
		cout << endl;
		
		*/
		
		auto p=a.back();
		if(p[0]==p[1] and p[1]==p[2] and sm.back()){
			Yout;
		}
		else{
			Nout;
		}
		
	}
	
	
}

int main(){
	solve();}
0