This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define int long long
using namespace std;
const int N = 500000 + 10;
const int mod = 998244353;
const int inf = 1e9;
int res[N],mx[N];
vector<int>segs[N];
vector<pair<int,int>>kveri[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,m,q;
cin >> n >> m >> q;
for(int i = 1; i <= m; i++) {
int l,r;
cin >> l >> r;
segs[r].pb(l);
}
for(int i = 1; i <= q; i++) {
int l,r;
cin >> l >> r;
kveri[r].pb({l,i});
}
for(int i = 1; i <= n; i++) {
for(auto X : segs[i]) {
for(int j = X; j <= i; j++) mx[j] = max(mx[j],X);
}
for(auto X : kveri[i]) {
int mn = inf;
for(int j = X.F; j <= i; j++) {
mn = min(mn,mx[j]);
}
if(mn >= X.F) res[X.S] = 1;
else res[X.S] = 0;
}
}
for(int i = 1; i <= q; i++) cout << (res[i] == 1 ? "YES\n" : "NO\n");
return 0;
}
# | 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... |