#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pb push_back
#define sp <<" "<<
#define cont(x) for(auto el:x) cout<<el<<' ';cout<<endl;
#define contp(x) for(auto el:x) cout<<el.fi<<'-'<<el.se<<' ';cout<<endl;
#define DEBUG(x) cout<<#x sp x<<endl;
#define carp(x,y) ((x%MOD)*(y%MOD))%MOD
#define topla(x,y) ((x%MOD)+(y%MOD))%MOD
#define mid (l+r)/2
const int MAXN=1e6+5;
const int MOD=1e9+7;
const int INF=1e18;
int n,m,q;
int sol[MAXN], sag[MAXN];
vi tut[MAXN], tut2[MAXN];
bool ans[MAXN];
int t[4*MAXN];
int lazy[4*MAXN];
void push(int nd,int l,int r){
    if(lazy[nd]==0 or l==r) return;
    lazy[nd*2]+=lazy[nd];
    lazy[nd*2+1]+=lazy[nd];
    t[nd*2]+=lazy[nd];
    t[nd*2+1]+=lazy[nd];
    lazy[nd]=0;
}
void update(int ql,int qr,int val,int nd=1,int l=1,int r=n){
    if(l>r or l>qr or r<ql) return;
    push(nd,l,r);
    if(ql<=l and r<=qr){
        t[nd]+=val;
        lazy[nd]+=val;
        return;
    }
    update(ql,qr,val,nd*2,l,mid);
    update(ql,qr,val,nd*2+1,mid+1,r);
    t[nd]=min(t[nd*2],t[nd*2+1]);
}
int query(int ql,int qr,int nd=1,int l=1,int r=n){
    if(l>r or l>qr or r<ql) return INF;
    push(nd,l,r);
    if(ql<=l and r<=qr) return t[nd];
    
    auto s1=query(ql,qr,nd*2,l,mid);
    auto s2=query(ql,qr,nd*2+1,mid+1,r);
    return min(s1,s2);
}
bool mm(pair<pii,int> a, pair<pii,int> b){
    if(a.fi.fi==b.fi.fi) return a.fi.se>b.fi.se;
    return a.fi.fi<b.fi.fi;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m>>q;
    FORE(i,1,m+1){
        cin>>sol[i]>>sag[i];
        update(sol[i],sag[i],1);
        tut[sag[i]].pb(i);
        tut2[sol[i]].pb(i);
    }
    vector<pair<pii,int>> vec;
    FORE(i,1,q+1){
        int s,e;
        cin>>s>>e;
        vec.pb({{s,e},i});
    }
    sort(all(vec),mm);
    vb sil(n+1,false);
    int pt=n;
    int pt2=0;
    FOR(i,vec.size()){
        int s=vec[i].fi.fi;
        int e=vec[i].fi.se;
        int ind=vec[i].se;
        //cout<<"q" sp s sp e sp ind<<endl;
        
        if(pt>e){
            while(pt>e){
                for(auto el:tut[pt]){
                    if(!sil[el]){
                        //cout<<"sil" sp el<<endl;
                        update(sol[el],sag[el],-1);
                        sil[el]=true;
                    }
                }
                pt--;
            }
        }
        else if(pt<=e){
            while(pt<=e){
                for(auto el:tut[pt]){
                    if(sil[el] and sol[el]>=s){
                        //cout<<"ekle" sp el<<endl;
                        update(sol[el],sag[el],1);
                        sil[el]=false;
                    }   
                }
                pt++;
            }
        }
        while(pt2<s){
            for(auto el:tut2[pt2]){
                if(!sil[el]){
                    //cout<<"sil" sp el<<endl;
                    update(sol[el],sag[el],-1);
                    sil[el]=true;
                }
            }
            pt2++;
        }
        if(query(s,e)>0) ans[ind]=true;
        else ans[ind]=false;
    }
    FORE(i,1,q+1) cout<<(ans[i]?"YES":"NO")<<endl;
}   
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |