Submission #1009187

#TimeUsernameProblemLanguageResultExecution timeMemory
1009187Khanhcsp2Curtains (NOI23_curtains)C++14
100 / 100
928 ms88148 KiB
#include<bits/stdc++.h> #define el '\n' #define fi first #define sc second #define int ll #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; using ll=long long; using ull=unsigned long long; using ld=long double; const int mod=1e9+7; const int N=5e5+11; int n, m, q, l, r, nod[4*N], lazy[4*N], ans[N]; vector<int> rr[N]; vector<pii> qq[N]; void down(int id, int l, int r) { lazy[id*2]=max(lazy[id*2], lazy[id]); lazy[id*2+1]=max(lazy[id*2+1], lazy[id]); nod[id*2]=max(nod[id*2], lazy[id*2]); nod[id*2+1]=max(nod[id*2+1], lazy[id*2+1]); } void update(int id, int l, int r, int u, int v, int val) { if(r<u || v<l) return; if(u<=l && r<=v) { lazy[id]=max(lazy[id], val); nod[id]=max(nod[id], val); return; } down(id, l, r); int mid=(l+r)/2; update(id*2, l, mid, u, v, val); update(id*2+1, mid+1, r, u, v, val); nod[id]=min(nod[id*2], nod[id*2+1]); } int get(int id, int l, int r, int u, int v) { if(r<u || v<l) return 1e9; if(u<=l && r<=v) return nod[id]; down(id, l, r); int mid=(l+r)/2; return min(get(id*2, l, mid, u, v), get(id*2+1, mid+1, r, u, v)); } void sol() { cin >> n >> m >> q; for(int i=1;i<=m;i++) { cin >> l >> r; rr[r].push_back(l); } for(int i=1;i<=q;i++) { cin >> l >> r; qq[r].push_back({l, i}); } for(int r=1;r<=n;r++) { for(int l:rr[r]) update(1, 1, n, l, r, l); for(auto [l, id]:qq[r]) { if(get(1, 1, n, l, r)>=l) ans[id]=1; } } for(int i=1;i<=q;i++) { if(ans[i]) cout << "YES" << el; else cout << "NO" << el; } } signed main() { // freopen("divisor.INP", "r", stdin); // freopen("divisor.OUT", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin >> t; while(t--) { sol(); } }

Compilation message (stderr)

curtains.cpp: In function 'void sol()':
curtains.cpp:64:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |         for(auto [l, id]:qq[r])
      |                  ^
#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...