#include #include using namespace std; using ll = long long; using ld = long double; using Pair = pair; using Tuple = tuple; using VI1 = vector; using VI2 = vector; using VL1 = vector; using VL2 = vector; using VD1 = vector; using VD2 = vector; using VB1 = vector; using VB2 = vector; using VP1 = vector; using VP2 = vector; using VT1 = vector; using VT2 = vector; using Queue = queue; using DQ = deque; using PQ = priority_queue, greater>; using Table = VI2; using Graph = VI2; using FW = atcoder::fenwick_tree; /** io */ template std::vector input_vec(int N); template void output_row(std::vector &row); template void output_col(std::vector &col); void outputYesNo(bool yes, const string &Yes = "Yes", const string &No = "No"); /** minmax */ template bool chmin(T &a, T b); template bool chmax(T &a, T b); template struct CoordinateCompressor { bool compressed; int size_values, size_uniques; vector original_values, uniques; vector compressed_values; CoordinateCompressor() : compressed(false), size_values(0), size_uniques(0), original_values(), uniques(), compressed_values() {} CoordinateCompressor(const vector &original_values) : compressed(false), size_values(original_values.size()), size_uniques(0), original_values(original_values), uniques(), compressed_values() {} void add(const T &value) { assert(!compressed); original_values.emplace_back(value); ++size_values; compressed = false; } void compress() { if (compressed) return; uniques = original_values; sort(uniques.begin(), uniques.end()); uniques.erase(unique(uniques.begin(), uniques.end()), uniques.end()); size_uniques = uniques.size(); compressed_values.resize(size_values); for (int i = 0; i < size_values; ++i) { auto oi = original_values.at(i); auto it = lower_bound(uniques.begin(), uniques.end(), oi); compressed_values.at(i) = it - uniques.begin(); } compressed = true; } const T &at(int i) { if (!compressed) compress(); return uniques.at(i); } int operator()(const T &value) { if (!compressed) compress(); auto it = lower_bound(uniques.begin(), uniques.end(), value); return it - uniques.begin(); } const T &get_original(int i) { return original_values.at(i); } int get_compressed(int i) { if (!compressed) compress(); return compressed_values.at(i); } int nunique() { if (!compressed) compress(); return size_uniques; } bool has(const T &value) { auto i = operator()(value); if (i == size_uniques) return false; return (uniques.at(i) == value); } }; using CCI = CoordinateCompressor; using CCS = CoordinateCompressor; void update(CCI &cci, CCS &ccs, string &Xi, int Li, int Ri, vector> &member2term, FW &fw) { auto j = ccs(Xi); auto a = cci(Li); auto b = cci(Ri); member2term.at(j).emplace(a, b); fw.add(a, 1); fw.add(b, -1); } auto solve() { int N; cin >> N; vector X(N); VI1 L(N), R(N); for (int i = 0; i < N; ++i) { cin >> X.at(i) >> L.at(i) >> R.at(i); ++R.at(i); } int Q; cin >> Q; VI1 type(Q), t(Q), l(Q), r(Q); vector x(Q); for (int i = 0; i < Q; ++i) { cin >> type.at(i); if (type.at(i) == 1) { cin >> x.at(i) >> t.at(i); } if (type.at(i) == 2) { cin >> t.at(i); } if (type.at(i) == 3) { cin >> x.at(i) >> l.at(i) >> r.at(i); ++r.at(i); } } CCI cci; CCS ccs; for (int i = 0; i < N; ++i) { ccs.add(X.at(i)); cci.add(L.at(i)); cci.add(R.at(i)); } for (int i = 0; i < Q; ++i) { auto type_i = type.at(i); if (type_i == 1) { ccs.add(x.at(i)); cci.add(t.at(i)); } if (type_i == 2) { cci.add(t.at(i)); } if (type_i == 3) { ccs.add(x.at(i)); cci.add(l.at(i)); cci.add(r.at(i)); } } cci.compress(); ccs.compress(); int M = ccs.nunique(); int T = cci.nunique(); vector> member2term(M); FW fw(T); for (int i = 0; i < N; ++i) { update(cci, ccs, X.at(i), L.at(i), R.at(i), member2term, fw); } for (int i = 0; i < Q; ++i) { auto type_i = type.at(i); if (type_i == 1) { auto j = ccs(x.at(i)); auto a = cci(t.at(i)); auto &term = member2term.at(j); auto it = prev(term.upper_bound({a, T})); if (it == term.end()) { cout << "No\n"; continue; } if (it->first <= a && a < it->second) { cout << "Yes\n"; } else { cout << "No\n"; } } if (type_i == 2) { auto a = cci(t.at(i)); cout << fw.sum(0, a + 1) << "\n"; } if (type_i == 3) { update(cci, ccs, x.at(i), l.at(i), r.at(i), member2term, fw); } } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); // cout << result << '\n'; // output_row(result); // output_col(result); // outputYesNo(result, "Yes", "No"); } } /** @note 使用頻度が高く毎回貼付するのが面倒なライブラリを実装しておく。*/ template std::vector input_vec(int N) { std::vector v(N); for (auto &vi : v) { cin >> vi; } return v; } void outputYesNo(bool yes, const string &Yes, const string &No) { if (yes) cout << Yes << '\n'; else cout << No << '\n'; } template void output_row(std::vector &row) { int N = row.size(); for (int i = 0; i < N; ++i) { if (i > 0) cout << ' '; cout << row.at(i); } cout << '\n'; } template void output_col(std::vector &col) { int N = col.size(); for (int i = 0; i < N; ++i) { cout << col.at(i) << '\n'; } } template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }