Submission #1100859

#TimeUsernameProblemLanguageResultExecution timeMemory
1100859imarnCurtains (NOI23_curtains)C++14
100 / 100
813 ms78920 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define plx pair<ll,int> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define vl vector<ll> #define vvi vector<vi> using namespace std; const int mxn=5e5+5; vector<int>upd[mxn]; vector<pii>qr[mxn]; int t[4*mxn],lz[4*mxn]{0}; void build(int i,int l,int r){ lz[i]=1e9; if(l==r)return void(t[i]=1e9); int m=(l+r)>>1;build(2*i,l,m);build(2*i+1,m+1,r); t[i]=max(t[2*i],t[2*i+1]); } void push(int i,int l,int r){ t[i]=min(t[i],lz[i]); if(l<r)lz[2*i]=min(lz[2*i],lz[i]),lz[2*i+1]=min(lz[2*i+1],lz[i]); lz[i]=1e9; } void update(int i,int l,int r,int tl,int tr,int v){ push(i,l,r); if(r<tl||l>tr)return; if(r<=tr&&l>=tl){ lz[i]=min(lz[i],v);push(i,l,r);return; }int m=(l+r)>>1;update(2*i,l,m,tl,tr,v);update(2*i+1,m+1,r,tl,tr,v); t[i]=max(t[2*i],t[2*i+1]); } int query(int i,int l,int r,int tl,int tr){ push(i,l,r); if(r<tl||l>tr)return 0; if(r<=tr&&l>=tl)return t[i]; int m=(l+r)>>1; return max(query(2*i,l,m,tl,tr),query(2*i+1,m+1,r,tl,tr)); } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,m,q;cin>>n>>m>>q; for(int i=1;i<=m;i++){ int l,r;cin>>l>>r; upd[l].pb(r); } for(int i=1;i<=q;i++){ int l,r;cin>>l>>r; qr[l].pb({r,i}); }build(1,1,n);int ans[q+1]={0}; for(int i=n;i>=1;i--){ for(auto it : upd[i])update(1,1,n,i,it,it); for(auto it : qr[i])ans[it.s]=(query(1,1,n,i,it.f)<=it.f); } for(int i=1;i<=q;i++)cout<<(ans[i]?"YES\n":"NO\n"); }
#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...