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 83
| #include <cstdio> #include <set> #include <algorithm> using namespace std; template <class Type> void read(Type &x) { char c; bool flag = false; while ((c = getchar()) < '0' || c > '9') c == '-' && (flag = true); x = c - '0'; while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0'; flag && (x = ~x + 1); } template <class Type> void write(Type x) { x < 0 && (putchar('-'), x = ~x + 1); x > 9 && (write(x / 10), 0); putchar(x % 10 + '0'); } template <class Type> void chkmin (Type &x, Type k) { k < x && (x = k); } const int N = 2e5 + 10; int n, m, tr[N << 2]; set <int> s; void build (int l = 1, int r = n, int x = 1) { tr[x] = n + 1; if (l == r) return; int mid = l + r >> 1; build(l, mid, x << 1), build(mid + 1, r, x << 1 | 1); } void modify (int t, int k, int l = 1, int r = n, int x = 1) { chkmin(tr[x], k); if (l == r) return; int mid = l + r >> 1; t <= mid ? modify(t, k, l, mid, x << 1) : modify(t, k, mid + 1, r, x << 1 | 1); } int query (int L, int R, int l = 1, int r = n, int x = 1) { if (l > R || L > r) return n + 1; if (l >= L && r <= R) return tr[x]; int mid = l + r >> 1; return min(query(L, R, l, mid, x << 1), query(L, R, mid + 1, r, x << 1 | 1)); } int main () { read(n), read(m); build(); for (int i = 0; i <= n + 1; i++) s.insert(i); for (int op; m; m--) { read(op); if (op == 0) { int l, r, x; read(l), read(r), read(x); if (x == 0) for (auto i = s.lower_bound(l); i != s.end() && *i <= r; i = s.erase(i)); else if (x == 1) modify(l, r); } else if (op == 1) { int x; read(x); puts(s.count(x) ? (query(*--s.lower_bound(x) + 1, x) < *s.upper_bound(x) ? "YES" : "N/A") : "NO"); } } return 0; }
|