#include<bits/stdc++.h>
#define ii pair<int, int>
#define ll pair<long long, long long>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int mod[2] = {1000000007, 998244353};
const int N = 5e5 + 1;
const string NAME = "";
int n, m, q;
vector<int> lft[N];
vector<ii> queries[N];
bool ans[N];
struct SegTree{
int n, h;
vector<int> tree, lazy;
SegTree(int _n) : n(_n){
tree.resize(2 * n);
lazy.resize(n);
h = sizeof(int) * 8 - __builtin_clz(n);
}
void build(){
for(int i = 0; i < 2 * n; ++i)
tree[i] = 0;
for(int i = 0; i < n; ++i)
lazy[i] = 0;
}
void up(int u){
while(u > 1)
u >>= 1, tree[u] = min(max(lazy[u], tree[u << 1]), max(lazy[u], tree[u << 1 | 1]));
}
void apply(int u, int val){
tree[u] = max(tree[u], val);
if(u < n)
lazy[u] = max(lazy[u], val);
}
void down(int u){
for(int s = h; s; --s){
int i = u >> s;
if(lazy[i]){
apply(i << 1, lazy[i]);
apply(i << 1 | 1, lazy[i]);
lazy[i] = 0;
}
}
}
void update(int l, int r, int val){
--l;
l += n, r += n;
int l0 = l, r0 = r;
for(; l < r; l >>= 1, r >>= 1){
if(l & 1)
apply(l++, val);
if(r & 1)
apply(--r, val);
}
up(l0);
up(r0 - 1);
}
int query(int l, int r){
l += n, r += n;
down(l);
down(r - 1);
int res = 2e9;
for(; l < r; l >>= 1, r >>= 1){
if(l & 1)
res = min(res, tree[l++]);
if(r & 1)
res = min(tree[--r], res);
}
return res;
}
};
void inp(){
cin >> n >> m >> q;
for(int i = 1; i <= m; ++i){
int l, r;
cin >> l >> r;
lft[r].pb(l);
}
for(int i = 1; i <= q; ++i){
int s, t;
cin >> s >> t;
queries[t].pb({s, i});
}
}
void solve(){
SegTree st(n);
for(int r = 1; r <= n; ++r){
for(int l : lft[r])
st.update(l, r, l);
for(auto [l, id] : queries[r])
ans[id] = (st.query(l, r) == l);
}
for(int i = 1; i <= q; ++i)
cout << (ans[i] ? "YES\n" : "NO\n");
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen((NAME + ".inp").c_str(), "r")){
freopen((NAME + ".inp").c_str(), "r", stdin);
freopen((NAME + ".out").c_str(), "w", stdout);
}
inp();
solve();
}
Compilation message (stderr)
curtains.cpp: In function 'int main()':
curtains.cpp:128:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
128 | freopen((NAME + ".inp").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:129:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
129 | freopen((NAME + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |