//line 1 "answer.cpp" #if !__INCLUDE_LEVEL__ #include __FILE__ int main() { ll n; input(n); map> mp; vector ci; debug(n); rep(i, n) { string x; ll l,r; input(x,l,r); ci.emplace_back(l); ci.emplace_back(r+1); mp[x].emplace(l,r); } debug("---"); repe(e, mp) { e.second.emplace(-INFL, -INFL); e.second.emplace(INFL, INFL); } debug("----"); ll q; input(q); vector> query1; vector> query2; vector> query3; vector qt(q); rep(i, q) { ll t; input(t); qt[i] = t; if (t == 1) { string x; ll y; input(x,y); query1.emplace_back(i, x, y); } else if (t == 2) { ll ti; input(ti); query2.emplace_back(i, ti); ci.emplace_back(ti); } else { string x; ll l,r; input(x,l,r); query3.emplace_back(i,x,l,r); ci.emplace_back(l); ci.emplace_back(r+1); if (mp[x].empty()) { mp[x].emplace(-INFL, -INFL); mp[x].emplace(INFL, INFL); continue; } } } Compress c(ci); lseg_max_radd seg(sz(c)); rep(i, sz(c)) { seg.set(i, 0); } repe(e, mp) { repe(e, e.second) { auto[l,r] = e; if (l == -INFL || l == INFL) continue; debug(l, r); seg.apply(c.pos(l), c.pos(r+1), 1); } } ll id1 = 0, id2 = 0, id3 = 0; rep(i, n) { if (qt[i] == 1) { auto [id, x, t] = query1[id1]; id1++; debug(id, x, t); if (!mp.count(x)) { No(); continue; } auto iter = mp[x].upper_bound(make_pair((ll)t, INFL)); --iter; auto [l, r] = *iter; Yes(in_range((ll)t, l, r+1)); } else if (qt[i] == 2) { auto [id, t] = query2[id2]; id2++; debug(id, t); print(seg.get(c.pos(t))); } else { auto [id, x, l, r] = query3[id3]; id3++; debug(id, x, l, r); mp[x].emplace(l, r); seg.apply(c.pos(l), c.pos(r+1),1); } } } #else //line 2 "/home/fujisawa/atcoder/competitive_library/competitive/std/std.hpp" #include #ifndef LOCAL_TEST #pragma GCC target ("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #endif // LOCAL_TEST using namespace std; // 型名の短縮 using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vvi = vector; using vvvi = vector; using vl = vector; using vvl = vector; using vvvl = vector; using vb = vector; using vvb = vector; using vvvb = vector; using vc = vector; using vvc = vector; using vvvc = vector; using vd = vector; using vvd = vector; using vvvd = vector; using vs = vector; using vvs = vector>; using vvvs = vector>>; template vector> vv(int h, int w, T val = T()) { return vector(h, vector(w, val)); } template vector>> vvv(int h1, int h2, int h3, T val = T()) { return vector(h1, vector(h2, vector(h3, val))); } template vector>>> vvvv(int h1, int h2, int h3, int h4, T val = T()) { return vector(h1, vector(h2, vector(h3, vector(h4, val)))); } template using priority_queue_min = priority_queue, greater>; // 定数の定義 constexpr double PI = 3.14159265358979323; constexpr int INF = 100100111; constexpr ll INFL = 3300300300300300491LL; float EPS = 1e-8; double EPSL = 1e-16; template bool eq(const T x, const T y) { return x == y; } template<> bool eq(const double x, const double y) { return abs(x - y) < EPSL; } template<> bool eq(const float x, const float y) { return abs(x - y) < EPS; } template bool neq(const T x, const T y) { return !(eq(x, y)); } template bool ge(const T x, const T y) { return (eq(x, y) || (x > y)); } template bool le(const T x, const T y) { return (eq(x, y) || (x < y)); } template bool gt(const T x, const T y) { return !(le(x, y)); } template bool lt(const T x, const T y) { return !(ge(x, y)); } constexpr int MODINT998244353 = 998244353; constexpr int MODINT1000000007 = 1000000007; // 入出力高速化 struct Nyan { Nyan() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } nyan; // 汎用マクロの定義 #define all(a) (a).begin(), (a).end() #define sz(x) ((ll)(x).size()) #define rep1(n) for(ll dummy_iter = 0LL; dummy_iter < n; ++dummy_iter) // 0 から n-1 まで昇順 #define rep2(i, n) for(ll i = 0LL, i##_counter = 0LL; i##_counter < ll(n); ++(i##_counter), (i) = i##_counter) // 0 から n-1 まで昇順 #define rep3(i, s, t) for(ll i = ll(s), i##_counter = ll(s); i##_counter < ll(t); ++(i##_counter), (i) = (i##_counter)) // s から t まで昇順 #define rep4(i, s, t, step) for(ll i##_counter = step > 0 ? ll(s) : -ll(s), i##_end = step > 0 ? ll(t) : -ll(t), i##_step = abs(step), i = ll(s); i##_counter < i##_end; i##_counter += i##_step, i = step > 0 ? i##_counter : -i##_counter) // s から t まで stepずつ #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define repe(a, v) for(auto& a : (v)) // v の全要素(変更可能) #define smod(n, m) ((((n) % (m)) + (m)) % (m)) // 非負mod #define sdiv(n, m) (((n) - smod(n, m)) / (m)) // 非負div #define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());} // 重複除去 int Yes(bool b=true) { cout << (b ? "Yes\n" : "No\n"); return 0; }; int YES(bool b=true) { cout << (b ? "YES\n" : "NO\n"); return 0; }; int No(bool b=true) {return Yes(!b);}; int NO(bool b=true) {return YES(!b);}; template T max(array& a) { return *max_element(all(a)); }; template T min(array& a) { return *min_element(all(a)); }; template T max(vector& a) { return *max_element(all(a)); }; template T min(vector& a) { return *min_element(all(a)); }; template vector vec_slice(const vector& a, int l, int r) { vector rev; rep(i, l, r) rev.push_back(a[i]); return rev; }; template T sum(vector& a, T zero = T(0)) { T rev = zero; rep(i, sz(a)) rev += a[i]; return rev; }; template bool in_range(const T& val, const T& s, const T& t) { return s <= val && val < t; }; template inline vector& operator--(vector& v) { repe(x, v) --x; return v; } template inline vector& operator++(vector& v) { repe(x, v) ++x; return v; } // modでのpow ll powm(ll a, ll n, ll mod=INFL) { ll res = 1; while (n > 0) { if (n & 1) res = (res * a) % mod; if (n > 1) a = (a * a) % mod; n >>= 1; } return res; } // 整数Sqrt ll sqrtll(ll x) { assert(x >= 0); ll rev = sqrt(x); while(rev * rev > x) --rev; while((rev+1) * (rev+1)<=x) ++rev; return rev; } template inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新(更新されたら true を返す) template inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新(更新されたら true を返す) int digit(ll x, int d=10) { int rev=0; while (x > 0) { rev++; x /= d;}; return rev; } // xのd進数桁数 /** * @brief std.hpp * @docs docs/std/std.md */ //line 6 "/home/fujisawa/atcoder/competitive_library/atcoder/lazysegtree.hpp" //line 2 "/home/fujisawa/atcoder/competitive_library/atcoder/internal_bit.hpp" #ifdef _MSC_VER #include #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } // @param n `1 <= n` // @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0` constexpr int bsf_constexpr(unsigned int n) { int x = 0; while (!(n & (1 << x))) x++; return x; } // @param n `1 <= n` // @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0` int bsf(unsigned int n) { #ifdef _MSC_VER unsigned long index; _BitScanForward(&index, n); return index; #else return __builtin_ctz(n); #endif } } // namespace internal } // namespace atcoder //line 8 "/home/fujisawa/atcoder/competitive_library/atcoder/lazysegtree.hpp" namespace atcoder { template struct lazy_segtree { public: S (*op)(S, S) = _op; S (*e)() = _e; S (*mapping)(F, S) = _mapping; F (*composition)(F, F) = _composition; F (*id)() = _id; lazy_segtree() : lazy_segtree(0) {} explicit lazy_segtree(int n) : lazy_segtree(std::vector(n, _e())) {} explicit lazy_segtree(const std::vector& v) : _n(int(v.size())) { log = internal::ceil_pow2(_n); size = 1 << log; d = std::vector(2 * size, e()); lz = std::vector(size, id()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } void add(int p, S x) { assert(0 <= p && p < _n); (*this).set(p, (*this).get(p) + x); } S get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return d[p]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); if (l == r) return e(); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } S sml = e(), smr = e(); while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } void apply(int p, F f) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = mapping(f, d[p]); for (int i = 1; i <= log; i++) update(p >> i); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } { int l2 = l, r2 = r; while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } l = l2; r = r2; } for (int i = 1; i <= log; i++) { if (((l >> i) << i) != l) update(l >> i); if (((r >> i) << i) != r) update((r - 1) >> i); } } template int max_right(int l) { return max_right(l, [](S x) { return g(x); }); } template int max_right(int l, G g) { assert(0 <= l && l <= _n); assert(g(e())); if (l == _n) return _n; l += size; for (int i = log; i >= 1; i--) push(l >> i); S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!g(op(sm, d[l]))) { while (l < size) { push(l); l = (2 * l); if (g(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template int min_left(int r) { return min_left(r, [](S x) { return g(x); }); } template int min_left(int r, G g) { assert(0 <= r && r <= _n); assert(g(e())); if (r == 0) return 0; r += size; for (int i = log; i >= 1; i--) push((r - 1) >> i); S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!g(op(d[r], sm))) { while (r < size) { push(r); r = (2 * r + 1); if (g(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } int n() {return (*this)._n;} private: int _n, size, log; std::vector d; std::vector lz; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } void all_apply(int k, F f) { d[k] = mapping(f, d[k]); if (k < size) lz[k] = composition(f, lz[k]); } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; } // namespace atcoder //line 4 "/home/fujisawa/atcoder/competitive_library/competitive/data_structure/lazysegtree.hpp" template std::ostream& operator<<(std::ostream& os, atcoder::lazy_segtree seg) { int n = seg.n(); rep(i, n) { os << seg.get(i); if (i != n-1) os << " "; } return os; }; namespace lsegtree_internal { template struct AddNode { T value; ll size; AddNode() : value(T(0)), size(1) {}; AddNode(T value, ll size) : value(value), size(size) {}; friend ostream& operator<<(std::ostream& os, const AddNode &n) { os << n.value; return os; }; }; template T e_max() { return -INFL; } template<> int e_max() { return -INF; } template T e_min() { return INFL; } template<> int e_min() { return INF; } template AddNode e_add() { return {0, 1}; } template T op_max(T x, T y) { return x > y ? x : y; } template T op_min(T x, T y) { return x < y ? x : y; } template AddNode op_add(AddNode x, AddNode y) { return {x.value + y.value, x.size + y.size}; } template T id_radd(){ return 0; } template T id_rupdate(){ return INFL; } template<> int id_rupdate(){ return INF; } template AddNode mapping_add_radd(T f, AddNode x){ return {x.value + f * x.size, x.size}; } template AddNode mapping_add_rupdate(T f, AddNode x){ AddNode rev = AddNode(x); if(f != id_rupdate()) rev.value = f * rev.size; return rev; } template T mapping_radd(T f, T x){ return f+x; } template T mapping_rupdate(T f, T x){ return (f == id_rupdate() ? x : f); } template T composition_radd(T f, T g){ return f+g; } template T composition_rupdate(T f, T g){ return (f == id_rupdate() ? g : f); } } template using lsegtree = atcoder::lazy_segtree; template using lseg_add_radd = atcoder::lazy_segtree, lsegtree_internal::op_add, lsegtree_internal::e_add, T, lsegtree_internal::mapping_add_radd, lsegtree_internal::composition_radd, lsegtree_internal::id_radd>; template using lseg_min_radd = atcoder::lazy_segtree, lsegtree_internal::e_min, T, lsegtree_internal::mapping_radd, lsegtree_internal::composition_radd, lsegtree_internal::id_radd>; template using lseg_max_radd = atcoder::lazy_segtree, lsegtree_internal::e_max, T, lsegtree_internal::mapping_radd, lsegtree_internal::composition_radd, lsegtree_internal::id_radd>; template using lseg_add_rupdate = atcoder::lazy_segtree, lsegtree_internal::op_add, lsegtree_internal::e_add, T, lsegtree_internal::mapping_add_rupdate, lsegtree_internal::composition_rupdate, lsegtree_internal::id_rupdate>; template using lseg_min_rupdate = atcoder::lazy_segtree, lsegtree_internal::e_min, T, lsegtree_internal::mapping_rupdate, lsegtree_internal::composition_rupdate, lsegtree_internal::id_rupdate>; template using lseg_max_rupdate = atcoder::lazy_segtree, lsegtree_internal::e_max, T, lsegtree_internal::mapping_rupdate, lsegtree_internal::composition_rupdate, lsegtree_internal::id_rupdate>; /** * @brief 遅延セグメント木(ラッパー) * @docs docs/data_structure/lazysegtree.md */ //line 3 "/home/fujisawa/atcoder/competitive_library/competitive/helper/compress.hpp" template struct Compress { vector coordinates; vector val; Compress() = default; Compress(const vector &_coordinates, Val default_val = Val(0)) { coordinates = _coordinates; uniq(coordinates); val = vector(sz(coordinates), default_val); } int pos(const Key key) const { auto iter = lower_bound(all(coordinates), key); assert(iter != coordinates.end() && *iter == key); return distance(coordinates.begin(), iter); } Val& operator[](Key key) { return val[pos(key)]; } const Val& operator[](const Key key) const { return val[pos(key)]; } Key key_at(const int i) const { return coordinates[i]; } size_t size() const { return coordinates.size(); } }; /** * @brief 座標圧縮 * @docs docs/helper/compress.md */ //line 3 "/home/fujisawa/atcoder/competitive_library/competitive/std/io.hpp" // 演算子オーバーロード(プロトタイプ宣言) template inline istream& operator>>(istream& is, pair& p); template inline istream& operator>>(istream& is, vector& v); template inline ostream& operator<<(ostream& os, const pair& p); template inline ostream& operator<<(ostream& os, const vector& v); template ostream &operator<<(ostream &os, const map &mp); template ostream &operator<<(ostream &os, const set &st); template ostream &operator<<(ostream &os, const multiset &st); template ostream &operator<<(ostream &os, const unordered_set &st); template ostream &operator<<(ostream &os, queue q); template ostream &operator<<(ostream &os, deque q); template ostream &operator<<(ostream &os, stack st); template ostream &operator<<(ostream &os, priority_queue pq); // 演算子オーバーロード template inline istream& operator>>(istream& is, pair& p) { is >> p.first >> p.second; return is; } template inline istream& operator>>(istream& is, vector& v) { repe(x, v) is >> x; return is; } template inline ostream& operator<<(ostream& os, const pair& p) { os << p.first << " " << p.second; return os; } template inline ostream& operator<<(ostream& os, const vector& v) { rep(i, sz(v)) { os << v.at(i); if (i != sz(v) - 1) os << " "; } return os; } template ostream &operator<<(ostream &os, const map &mp) { for (auto &[key, val] : mp) { os << key << ":" << val << " "; } return os; } template ostream &operator<<(ostream &os, const set &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; } template ostream &operator<<(ostream &os, const multiset &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; } template ostream &operator<<(ostream &os, const unordered_set &st) { ll cnt = 0; for (auto &e : st) { os << e << (++cnt != (int)st.size() ? " " : ""); } return os; } template ostream &operator<<(ostream &os, queue q) { while (q.size()) { os << q.front() << " "; q.pop(); } return os; } template ostream &operator<<(ostream &os, deque q) { while (q.size()) { os << q.front() << " "; q.pop_front(); } return os; } template ostream &operator<<(ostream &os, stack st) { while (st.size()) { os << st.top() << " "; st.pop(); } return os; } template ostream &operator<<(ostream &os, priority_queue pq) { while (pq.size()) { os << pq.top() << " "; pq.pop(); } return os; } template int print_sep_end(string sep, string end, const T& val) { (void)sep; cout << val << end; return 0; }; template int print_sep_end(string sep, string end, const T1 &val, const T2 &...remain) { cout << val << sep; print_sep_end(sep, end, remain...); return 0; }; template int print(const T &...args) { print_sep_end(" ", "\n", args...); return 0; }; template void flush() { cout << flush; }; template int print_and_flush(const T &...args) { print(args...); flush(); return 0; }; #define debug(...) debug_func(0, #__VA_ARGS__, __VA_ARGS__) // debug print template void input(T &a) { cin >> a; }; template void input(T1&a, T2 &...b) { cin >> a; input(b...); }; #ifdef LOCAL_TEST template void debug_func(int i, const T name) { (void)i; (void)name; cerr << endl; } template void debug_func(int i, const T1 &name, const T2 &a, const T3 &...b) { int scope = 0; for ( ; (scope != 0 || name[i] != ',') && name[i] != '\0'; i++ ) { cerr << name[i]; if (name[i] == '(' || name[i] == '{') scope++; if (name[i] == ')' || name[i] == '}') scope--; } cerr << ":" << a << " "; debug_func(i + 1, name, b...); } template void debug_func(int i, const T1 &name, T2 &a, T3 &...b) { int scope = 0; for ( ; (scope != 0 || name[i] != ',') && name[i] != '\0'; i++ ) { cerr << name[i]; if (name[i] == '(' || name[i] == '{') scope++; if (name[i] == ')' || name[i] == '}') scope--; } cerr << ":" << a << " "; debug_func(i + 1, name, b...); } #endif #ifndef LOCAL_TEST template void debug_func(T &...) {} template void debug_func(const T &...) {} #endif /** * @brief io.hpp * @docs docs/std/io.md */ //line 100 "answer.cpp" #endif