Submission #882929

#TimeUsernameProblemLanguageResultExecution timeMemory
882929tsumondaiCurtains (NOI23_curtains)C++14
100 / 100
794 ms73892 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) #define __TIME (1.0 * clock() / CLOCKS_PER_SEC) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 5e5 + 5; const int oo = 1e9, mod = 1e9 + 7; int n, m, k, q; bool res[N]; vector<int> events[N]; vector<ii> queries[N]; void maximize (int &a, int b) { a = max(a, b); } struct STree { int node[N * 4], lazy[N * 4]; void down (int id, int l, int r) { if (lazy[id] == 0) return; maximize(node[id], lazy[id]); if (l != r) { maximize(lazy[id * 2], lazy[id]); maximize(lazy[id * 2 + 1], lazy[id]); } lazy[id] = 0; } void update (int id, int l, int r, int u, int v, int val) { down(id, l, r); if (l > v || r < u) return; if (l >= u && r <= v) { lazy[id] = val; down(id, l, r); return; } int mid = l + r >> 1; update(id * 2, l, mid, u, v, val); update(id * 2 + 1, mid + 1, r, u, v, val); node[id] = min(node[id * 2], node[id * 2 + 1]); } int get (int id, int l, int r, int u, int v) { down(id, l, r); if (l > v || r < u) return 1e9; if (l >= u && r <= v) return node[id]; int mid = l + r >> 1; return min(get(id * 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v)); } } st; void process() { cin >> n >> m >> q; foru(i, 1, m) { int l, r; cin >> l >> r; events[r].push_back(l); } foru(i, 1, q) { int l, r; cin >> l >> r; queries[r].push_back({l, i}); } foru(r, 1, n) { for (int l : events[r]) { st.update(1, 1, n, l, r, l); } for (ii it : queries[r]) { int l = it.fi; int id = it.se; if (st.get(1, 1, n, l, r) >= l) { res[id] = true; } } } foru(i, 1, q) { cout << (res[i] ? "YES\n" : "NO\n"); } return; } signed main() { cin.tie(0)->sync_with_stdio(false); //freopen(".inp", "r", stdin); //freopen(".out", "w", stdout); process(); cerr << "Time elapsed: " << __TIME << " s.\n"; return 0; } /* Xét các trường hợp đặc biệt Kiểm tra lại input/output Cố gắng trâu Lật ngược bài toán Keep calm and get VOI Flow: */

Compilation message (stderr)

curtains.cpp: In member function 'void STree::update(int, int, int, int, int, int)':
curtains.cpp:50:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |   int mid = l + r >> 1;
      |             ~~^~~
curtains.cpp: In member function 'int STree::get(int, int, int, int, int)':
curtains.cpp:60:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   60 |   int mid = l + r >> 1;
      |             ~~^~~
#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...