제출 #1124400

#제출 시각아이디문제언어결과실행 시간메모리
1124400HiepVu217Curtains (NOI23_curtains)C++20
100 / 100
696 ms37972 KiB
#include <bits/stdc++.h> #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") using namespace std; const int N = 5e5 + 17; int n, m, q, st[4 * N], lz[4 * N]; string ans[N]; struct qrs { int l, r, id; bool operator < (const qrs &o) const { if (r != o.r) { return r < o.r; } return id < o.id; } } qr[2 * N]; inline void down (int id) { st[id * 2] = max (lz[id], st[id * 2]); lz[id * 2] = max (lz[id], lz[id * 2]); st[id * 2 + 1] = max (lz[id], st[id * 2 + 1]); lz[id * 2 + 1] = max (lz[id], lz[id * 2 + 1]); lz[id] = 0; } inline void update (int id, int l, int r, int u, int v, int x) { if (v < l || r < u) { return; } if (u <= l && r <= v) { st[id] = max (st[id], x); lz[id] = max (lz[id], x); return; } int mid = l + r >> 1; down(id); update (id * 2, l, mid, u, v, x); update (id * 2 + 1, mid + 1, r, u, v, x); st[id] = min (st[id * 2], st[id * 2 + 1]); } inline int get (int id, int l, int r, int u, int v) { if (v < l || r < u) { return n + 1; } if (u <= l && r <= v) { return st[id]; } int mid = l + r >> 1; down(id); return min (get (id * 2, l, mid, u, v), get (id * 2 + 1, mid + 1, r, u, v)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> q; for (int i = 1, l, r; i <= m; ++i) { cin >> l >> r; qr[i] = {l, r, 0}; } for (int i = 1, l, r; i <= q; ++i) { cin >> l >> r; qr[m + i] = {l, r, i}; } sort (qr + 1, qr + m + q + 1); for (int i = 1; i <= m + q; ++i) { auto [l, r, id] = qr[i]; if (id) { ans[id] = (get (1, 1, n, l, r) == l ? "YES\n" : "NO\n"); continue; } update (1, 1, n, l, r, l); } for (int i = 1; i <= q; ++i) { cout << ans[i]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...