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>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
struct ST{
vector<int> a;
int n;
ST(int ns){
n = ns;
a.resize(n + 1);
}
void chmax(int l, int r, int x){
for (int i = l; i <= r; i++){
a[i] = max(a[i], x);
}
}
int get(int l, int r){
int mn = n + 1;
for (int i = l; i <= r; i++){
mn = min(mn, a[i]);
}
return mn;
}
};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, q; cin>>n>>m>>q;
vector<int> st[n + 1];
while (m--){
int l, r; cin>>l>>r;
st[r].pb(l);
}
vector<pii> qs[n + 1];
for (int i = 1; i <= q; i++){
int l, r; cin>>l>>r;
qs[r].pb({l, i});
}
vector<int> out(q + 1);
ST T(n);
for (int r = 1; r <= n; r++){
for (int l: st[r]){
T.chmax(l, r, l);
}
for (auto [l, i]: qs[r]){
out[i] = (T.get(l, r) >= l);
}
}
for (int i = 1; i <= q; i++){
cout<<(out[i] ? "YES" : "NO")<<"\n";
}
}
# | 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... |