1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| #include<bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, T; set<int>s; namespace Seg{ #define l(x) (x << 1) #define r(x) (x << 1 | 1) struct Node{ int l, r, v; }tr[N << 2]; inline void pushup(int x) { tr[x].v = min(tr[l(x)].v, tr[r(x)].v); } inline void change(int x, int w) { tr[x].v = min(tr[x].v, w); } void build(int x, int l, int r) { tr[x] = {l, r, n + 1}; if(l == r) return ; int mid = l + r >> 1; build(x << 1, l, mid); build(x << 1 | 1, mid + 1, r); pushup(x); } void modify(int x, int l, int r, int w) { if(tr[x].l == tr[x].r) return change(x, w); int mid = tr[x].l + tr[x].r >> 1; if(l <= mid) modify(x << 1, l, r, w); else modify(x << 1 | 1, l, r, w); pushup(x); } int query(int x, int l, int r) { if(l <= tr[x].l && tr[x].r <= r) return tr[x].v; int mid = tr[x].l + tr[x].r >> 1, res = n + 1; if(l <= mid) res = min(res, query(x << 1, l, r)); if(r > mid) res = min(res, query(x << 1 | 1, l, r)); return res; } } int main() { scanf("%d%d", &n, &m); Seg:: build(1, 1, n); for(int i = 0;i <= n + 1;i ++) s.insert(i); int op, l, r, x; while(m --) { scanf("%d", &op); if(op == 0) { scanf("%d%d%d", &l, &r, &x); if(x == 0) { while(!s.empty()) { x = *s.lower_bound(l); if(x > r) break; s.erase(x); } continue; } else Seg:: modify(1, l, r, r); } else{ scanf("%d", &x); if(!s.count(x)) puts("NO"); else{ auto st = s.lower_bound(x), ed = s.upper_bound(x); st --; if(Seg:: query(1, (*st) + 1, x) < *ed) puts("YES"); else puts("N/A"); } } } return 0; }
|