Submission #998843

#TimeUsernameProblemLanguageResultExecution timeMemory
998843LOLOLOCurtains (NOI23_curtains)C++17
100 / 100
688 ms74576 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define f first #define s second #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (ll)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) #define len(x) (int)(x.length()) const int N = 5e5 + 10; int st[N * 4], laz[N * 4]; void push(int id) { int t = laz[id]; laz[id * 2] = max(laz[id * 2], t); laz[id * 2 + 1] = max(laz[id * 2 + 1], t); st[id * 2] = max(st[id * 2], t); st[id * 2 + 1] = max(st[id * 2 + 1], t); } void upd(int id, int l, int r, int u, int v, int c) { if (l > v || r < u) return; if (l >= u && r <= v) { laz[id] = max(laz[id], c); st[id] = max(st[id], c); return; } push(id); int m = (l + r) / 2; upd(id * 2, l, m, u, v, c); upd(id * 2 + 1, m + 1, r, u, v, c); st[id] = min(st[id * 2], st[id * 2 + 1]); } int get(int id, int l, int r, int u, int v) { if (l > v || r < u) return 1e9; if (l >= u && r <= v) return st[id]; push(id); int m = (l + r) / 2; return min(get(id * 2, l, m, u, v), get(id * 2 + 1, m + 1, r, u, v)); } vector <int> add[N]; vector <pair <int, int>> ask[N]; int ans[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, q; cin >> n >> m >> q; for (int i = 1; i <= m; i++) { int l, r; cin >> l >> r; add[r].pb(l); } for (int i = 1; i <= q; i++) { int l, r; cin >> l >> r; ask[r].pb({l, i}); } for (int i = 1; i <= n; i++) { for (auto x : add[i]) { upd(1, 1, n, x, i, x); } for (auto x : ask[i]) { ans[x.s] = get(1, 1, n, x.f, i) >= x.f; } } for (int i = 1; i <= q; i++) { if (ans[i]) { cout << "YES\n"; } else { cout << "NO\n"; } } return 0; }
#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...