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;
int r,c,n,t;
pair <int,int> a[200100];
int nxt[20][200100];
void out(bool x){
if (x)cout<<"Yes";
else cout<<"No";
cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
cin>>r>>c>>n;
for (int i = 1;i <= n;i ++){
cin>>a[i].first>>a[i].second;
}
sort(a+1,a+1+n);
for (int i = 1;i <= n;i ++){
nxt[0][i] = lower_bound(a+1,a+1+n,make_pair(a[i].first + 1,a[i].second)) - (a);
if (a[nxt[0][i]].first != a[i].first + 1)nxt[0][i] = n + 1;
}
nxt[0][n+1] = n+1;
for (int j = 1;j < 20;j ++){
for (int i = 1;i <= n+1;i ++){
nxt[j][i] = nxt[j-1][nxt[j-1][i]];
}
}
cin>>t;
while (t--){
int xs,ys,xe,ye;
cin>>xs>>ys>>xe>>ye;
int cur = lower_bound(a+1,a+1+n,make_pair(xs,ys)) - (a);
if (xs == xe){
out(ys <= ye);
}
else{
if (xs < xe){
int k = xe - xs - 1;
for (int j = 19;j >= 0;j --){
if ((1<<j) <= k){
k -= (1<<j);
cur = nxt[j][cur];
}
}
out(a[cur].first == xe - 1 && a[cur].second <= ye);
}
else{
out(0);
}
}
}
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... |