#include #include #include #include using namespace std; using ll = long long; #define rep(i, n) for(int i=0; i child = {nullptr, nullptr, nullptr}; Node(Node* p, char c): p(p), c(c) {} Node* get_child(char c) { if(c == '(') { if(child[0] == nullptr) { child[0] = new Node(this, '('); } return child[0]; } if(c == '|') { if(child[1] == nullptr) { child[1] = new Node(this, '|'); } return child[1]; } if(c == ')') { if(child[2] == nullptr) { child[2] = new Node(this, ')'); } return child[2]; } } }; int main() { Node* root = new Node(nullptr, '$'); Node* current = root; ll q; cin >> q; vector query(q); rep(i, q) { ll type; cin >> type; if(type == 1) { cin >> query[i]; current = current->get_child(query[i]); } else { query[i] = ' '; current = current->p; } } stack st; st.push('('); auto f = [&](auto&& f, Node* v) -> void { char need = st.top(); if(need == v->c) { if(need == '(') { st.pop(); st.push('|'); } if(need == '|') { st.pop(); st.push(')'); } if(need == ')') { st.pop(); } } else { st.push('$'); } v->status = st.size(); if(st.empty()) st.push('('); rep(i, 3) if(v->child[i] != nullptr) f(f, v->child[i]); if(st.top() == '(' && st.size() == 1) st.pop(); if(need == v->c && (need == '(' || need == '|')) { st.pop(); } if(need == v->c) { st.push(need); } else { st.pop(); } }; root->status = 0; f(f, root->get_child('(')); current = root; rep(i, q) { if(query[i] != ' ') current = current->get_child(query[i]); else current = current->p; cout << (current->status == 0 ? "Yes" : "No") << "\n"; } }