#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()
struct SegmentTree{
ll N;
vector<ll> st, lazy, arr;
SegmentTree(ll N, ll val=0): N(N), arr(N, val), st(4*N), lazy(4*N){
build(1, 0, N-1);
}
ll build(ll n, ll s, ll e){
if(s==e) return st[n]=arr[s];
ll mid=(s+e)/2;
return st[n]=build(n*2, s, mid)+build(n*2+1, mid+1, e);
}
void push(ll n){
st[n*2]+=lazy[n]; st[n*2+1]+=lazy[n];
lazy[n*2]+=lazy[n]; lazy[n*2+1]+=lazy[n];
lazy[n]=0;
}
void update(ll n, ll s, ll e, ll l, ll r, ll val){
if(s>=l && e<=r){
lazy[n]+=val;
st[n]+=val;
return ;
}
push(n);
ll mid=(s+e)/2;
if(mid>=l) update(n*2, s, mid, l, r, val);
if(mid<r) update(n*2+1, mid+1, e, l, r, val);
st[n]=min(st[n*2], st[n*2+1]);
}
ll query(ll n, ll s, ll e, ll l, ll r){
if(s>=l && e<=r) return st[n];
push(n);
ll mid=(s+e)/2, ans=ll_MAX;
if(mid>=l) ans=min(ans, query(n*2, s, mid, l, r));
if(mid<r) ans=min(ans, query(n*2+1, mid+1, e, l, r));
return ans;
}
ll query(ll l, ll r){
return query(1, 0, N-1, l, r);
}
void update(ll l, ll r, ll val){
return update(1, 0, N-1, l, r, val);
}
};
const ll SQRT=700;
int main(){
ll n, m, q;
cin>>n>>m>>q;
vector<vector<ll>> beg(n), end(n);
vector<pair<ll, ll>> ranges;
SegmentTree st(n);
for(ll i=0; i<m; i++){
ll a, b;
cin>>a>>b;
a--; b--;
ranges.emplace_back(a, b);
st.update(a, b, 1);
beg[a].push_back(i);
end[b].push_back(i);
}
vector<ll> pref(n), act(m, 1);
for(ll i=0; i<n; i++)
pref[i]=(i==0 ? 0:pref[i-1]+beg[i].size()+end[i].size());
priority_queue<array<ll, 4>, vector<array<ll, 4>>, greater<array<ll, 4>>> mo;
for(ll i=0; i<q; i++){
ll l, r;
cin>>l>>r;
l--; r--;
mo.push({pref[l]/SQRT, r, l, i});
}
ll cur_l=0, cur_r=n-1;
vector<bool> ans(q);
while(mo.size()){
auto [block, r, l, ind]=mo.top();
mo.pop();
for(ll i=cur_l; i<l; i++){
for(auto e:beg[i]) if(act[e]){
st.update(ranges[e].first, ranges[e].second, -1);
act[e]=0;
}
}
for(ll i=cur_r; i>r; i--){
for(auto e:beg[i]) if(act[e]){
st.update(ranges[e].first, ranges[e].second, -1);
act[e]=0;
}
}
for(ll i=cur_l; i>=l; i--){
for(auto e:beg[i]){
if(!act[e] && ranges[e].second<=r){
st.update(ranges[e].first, ranges[e].second, 1);
act[e]=1;
}
}
}
for(ll i=cur_r; i<=r; i++){
for(auto e:end[i]){
if(!act[e] && ranges[e].first>=l){
st.update(ranges[e].first, ranges[e].second, 1);
act[e]=1;
}
}
}
ans[ind]=(st.query(l, r)==0);
cur_l=l; cur_r=r;
}
for(ll i=0; i<q; i++) cout<<(ans[i] ? "NO":"YES")<<endl;
}
Compilation message
curtains.cpp: In constructor 'SegmentTree::SegmentTree(long long int, long long int)':
curtains.cpp:10:26: warning: 'SegmentTree::arr' will be initialized after [-Wreorder]
10 | vector<ll> st, lazy, arr;
| ^~~
curtains.cpp:10:16: warning: 'std::vector<long long int> SegmentTree::st' [-Wreorder]
10 | vector<ll> st, lazy, arr;
| ^~
curtains.cpp:12:5: warning: when initialized here [-Wreorder]
12 | SegmentTree(ll N, ll val=0): N(N), arr(N, val), st(4*N), lazy(4*N){
| ^~~~~~~~~~~
curtains.cpp: In member function 'long long int SegmentTree::query(long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:46:29: error: 'll_MAX' was not declared in this scope
46 | ll mid=(s+e)/2, ans=ll_MAX;
| ^~~~~~