#include #include #include #include #include using namespace std; using namespace atcoder; int op (int x, int y) { return x + y; } int e () { return 0; } int main () { // クエリ2 -> 座圧 + 区間加算、1点取得のセグ木。 // クエリ1と3 -> 人ごとにmapを持っておいて、lower_boundしましょう。 int N; cin >> N; map X_inv; vector X(N); vector L(N), R(N); for (int i = 0; i < N; i++) { cin >> X[i] >> L[i] >> R[i]; int len = (int) X_inv.size(); if (X_inv.find(X[i]) == X_inv.end()) X_inv[X[i]] = len; } int Q; cin >> Q; vector type(Q), l(Q), r(Q), t(Q); vector x(Q); for (int i = 0; i < Q; i++) { cin >> type[i]; if (type[i] == 1) { cin >> x[i] >> t[i]; int len = (int) X_inv.size(); if (X_inv.find(x[i]) == X_inv.end()) X_inv[x[i]] = len; } if (type[i] == 2) { cin >> t[i]; } if (type[i] == 3) { cin >> x[i] >> l[i] >> r[i]; int len = (int) X_inv.size(); if (X_inv.find(x[i]) == X_inv.end()) X_inv[x[i]] = len; } } // 座圧 vector f_inv; for (int i = 0; i < N; i++) { f_inv.push_back(L[i]); f_inv.push_back(R[i]); } for (int i = 0; i < Q; i++) { if (0 < l[i]) f_inv.push_back(l[i]); if (0 < r[i]) f_inv.push_back(r[i]); if (0 < t[i]) f_inv.push_back(t[i]); } sort(f_inv.begin(), f_inv.end()); f_inv.erase(unique(f_inv.begin(), f_inv.end()), f_inv.end()); map f; for (int i = 0; i < f_inv.size(); i++) f[f_inv[i]] = i; // セグ木 segtree seg(f.size() + 10); auto range_add = [&](int l, int r, int v) -> void { seg.set(l, seg.get(l) + v); seg.set(r, seg.get(r) - v); }; auto point_get = [&](int x) -> int { return seg.prod(0, x+1); }; for (int i = 0; i < N; i++) { range_add(f[L[i]], f[R[i]] + 1, 1); } // map enum STATE { IN, OUT, }; vector>> mp(X_inv.size()); for (int i = 0; i < N; i++) { int idx = X_inv[X[i]]; mp[idx][L[i]] = IN; mp[idx][R[i] + 1] = OUT; } // クエリ処理 for (int i = 0; i < Q; i++) { if (type[i] == 1) { int idx = X_inv[x[i]]; auto it = mp[idx].lower_bound(t[i]); if (it == mp[idx].end() || it->second == OUT) { cout << "No\n"; } else { cout << "Yes\n"; } } if (type[i] == 2) { cout << point_get(f[t[i]]) << "\n"; } if (type[i] == 3) { int idx = X_inv[x[i]]; mp[idx][l[i]] = IN; mp[idx][r[i] + 1] = OUT; range_add(f[l[i]], f[r[i]] + 1, 1); } } }