#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define LL __int128 #define ld long double #define INF 2251799813685248 #define rep(i, n) for (ll i = 0; i < (n); ++i) #define reps(i, l, r) for(ll i = (l); i < (r); ++i) #define foreach(c, A) for(auto c:(A)) #define vall(A) (A).begin(),(A).end() #define vrall(A) (A).rbegin(),(A).rend() #define slice(A, l, r) next((A).begin(), (l)), next((A).begin(), (r)) #define vin(A) for (ll iiii = 0, szszszsz = (A).size(); iiii < szszszsz; iiii++){cin >> (A)[iiii];} #define vout(A) for (ll iiii = 0, szszszsz = (A).size(); iiii < szszszsz; iiii++){cout << (A)[iiii] << " \n"[iiii == szszszsz-1];} #define vin2d(A) for (ll iiii = 0; iiii < (A).size(); iiii++){for (ll jjjj = 0; jjjj < (A)[iiii].size(); jjjj++){cin >> (A)[iiii][jjjj];}} #define vout2d(A) for (ll iiii = 0; iiii < (A).size(); iiii++){for (ll jjjj = 0; jjjj < (A)[iiii].size(); jjjj++){cout << (A)[iiii][jjjj] << " \n"[jjjj==(A)[iiii].size()-1];}} #define encode(i,j) (((i))<<32)+(j) #define decode(v,w) ((w) ? (v)%4294967296 : (v)>>32) #define vinc(A) for (auto &vvvv : (A)){vvvv++;} #define vdec(A) for (auto &vvvv : (A)){vvvv--;} #define graphin0(C, M) int aaaa,bbbb;for (int iiii = 0; iiii < (M); iiii++){cin >> aaaa >> bbbb; (C)[aaaa].push_back(bbbb); (C)[bbbb].push_back(aaaa);} #define graphin1(C, M) int aaaa,bbbb;for (int iiii = 0; iiii < (M); iiii++){cin >> aaaa >> bbbb; (C)[aaaa-1].push_back(bbbb-1); (C)[bbbb-1].push_back(aaaa-1);} #define lsegtype(name) name::S, name::F #define lsegarg(name) name::op, name::e,name::comp, name::mapping, name::id vector pow2ll{1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,4294967296,8589934592,17179869184,34359738368,68719476736,137438953472,274877906944,549755813888,1099511627776,2199023255552,4398046511104,8796093022208,17592186044416,35184372088832,70368744177664,140737488355328,281474976710656,562949953421312,1125899906842624,2251799813685248,4503599627370496,9007199254740992,18014398509481984,36028797018963968,72057594037927936,144115188075855872,288230376151711744,576460752303423488,1152921504606846976,2305843009213693952,4611686018427387904}; vector pow10ll{1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000,1000000000000,10000000000000,100000000000000,1000000000000000,10000000000000000,100000000000000000,1000000000000000000}; vector di{0,1,0,-1}; vector dj{1,0,-1,0}; template bool chmax(T &a, const T& b) { return a < b ? a = b, true : false; } template bool chmin(T &a, const T& b) { return a > b ? a = b, true : false; } unsigned int bit_length(ll n){ return n > 0 ? 64 - __builtin_clzll(n) : 0;} template T sum(vector A){ T res = 0; for (size_t i=0;i 0){ if ((n & 1) == 1){ ans *= p; ans %= m; } n >>= 1; p *= p; p %= m; } return (ll)ans; } template struct PersistentStack { struct Node { Node* parent; T value; }; Node* head = nullptr; size_t size_num = 0; PersistentStack(){} PersistentStack(const PersistentStack& ps) : head(ps.head), size_num(ps.size_num){} void push(T x){ Node* new_node = new Node{ this->head, x }; this->head = new_node; this->size_num += 1; } T top(){ assert(!this->empty()); return this->head->value; } T top_or(const T& v) { if(this->empty()) return v; return this->top(); } void pop(){ assert(!this->empty()); this->head = this->head->parent; this->size_num -= 1; } void pop_safe(){ if (!this->empty()){ this->head = this->head->parent; this->size_num -= 1; } } bool empty(){ return head == nullptr; } size_t size(){ return this->size_num; } PersistentStack clone(){ return *this; } operator vector(){ auto pt = this->clone(); vector memo(pt.size_num); for (int i = this->size_num-1; 0 <= i; i--){ memo[i] = pt.top(); pt.pop(); } return memo; } T operator[](int i){ assert(0 <= i < this->size_num); int step = this->size_num - i - 1; Node* tmp = head; while(step > 0){ step--; tmp = tmp->parent; } return tmp->value; } }; // =============================================================================== int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int Q; cin >> Q; PersistentStack S; vector> history; history.push_back(S.clone()); int t; char c; rep(i,Q){ cin >> t; if (t == 1){ cin >> c; S.push(c); int sz = S.size(); if (sz >= 3 && S[sz-3] == '(' && S[sz-2] == '|' && S[sz-1] == ')'){ S.pop(); S.pop(); S.pop(); } history.push_back(S.clone()); } else { history.pop_back(); S = history.back().clone(); } if (S.empty()){ cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } } } /* 5 1 ( 1 | 1 ) 2 1 | */