func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10, INF = 1e9;   struct event {     int pos, start, end, val, t, i;     event(int a, int b, int c, int d, int e, int f)         : pos(a), start(b), end(c), val(d), t(e), i(f){};   };   bool comp(event a, event b) {     if (a.pos != b.pos)       return a.pos < b.pos;     else       return a.t < b.t;   }   vector<event> vx, vy;   bool ok[MAXN];   int minx[MAXN], miny[MAXN];   int seg[4 * MAXN];   void clear(int i, int ini, int fim) {     seg[i] = 0;     if (ini == fim)       return;     else {       int mid = (ini + fim) / 2;       clear(i * 2, ini, mid);       clear(i * 2 + 1, mid + 1, fim);     }   }   void update(int i, int ini, int fim, int pos, int val) {     if (pos < ini || pos > fim)       return;     else {       if (ini == fim)         seg[i] = val;       else {         int mid = (ini + fim) / 2;         update(i * 2, ini, mid, pos, val);         update(i * 2 + 1, mid + 1, fim, pos, val);         seg[i] = min(seg[i * 2], seg[i * 2 + 1]);       }     }   }   int query(int i, int ini, int fim, int p, int q) {     if (ini >= p && fim <= q) return seg[i];     if (q < ini || p > fim)       return INF;     else {       int mid = (ini + fim) / 2;       return min(query(i * 2, ini, mid, p, q),                  query(i * 2 + 1, mid + 1, fim, p, q));     }   }   void print(int i, int ini, int fim) {     printf( i %d ini %d fim %d seg %d n , i, ini, fim, seg[i]);     if (ini != fim) {       int mid = (ini + fim) / 2;       print(i * 2, ini, mid);       print(i * 2 + 1, mid + 1, fim);     }   }   int main() {     int n, m, p, q;     scanf( %d %d %d %d , &n, &m, &p, &q);     for (int i = 0, a, b; i < p; i++) {       scanf( %d %d , &a, &b);       vx.push_back(event(a, 0, 0, b, 1, i));       vy.push_back(event(b, 0, 0, a, 1, i));     }     for (int i = 0, a, b, c, d; i < q; i++) {       scanf( %d %d %d %d , &a, &b, &c, &d);       vx.push_back(event(c, b, d, 0, 2, i));       vy.push_back(event(d, a, c, 0, 2, i));       minx[i] = a;       miny[i] = b;     }     sort(vx.begin(), vx.end(), comp);     sort(vy.begin(), vy.end(), comp);     clear(1, 1, max(m, n));     for (int i = 0; i < vx.size(); i++) {       if (vx[i].t == 1) {         update(1, 1, m, vx[i].val, vx[i].pos);       } else {         if (query(1, 1, m, vx[i].start, vx[i].end) >= minx[vx[i].i])           ok[vx[i].i] = 1;       }     }     clear(1, 1, max(m, n));     for (int i = 0; i < vy.size(); i++) {       if (vy[i].t == 1) {         update(1, 1, n, vy[i].val, vy[i].pos);       } else {         if (query(1, 1, n, vy[i].start, vy[i].end) >= miny[vy[i].i])           ok[vy[i].i] = 1;       }     }     for (int i = 0; i < q; i++) {       if (ok[i])         printf( YES n );       else         printf( NO n );     }   }   