// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
using namespace std;
#define int long long
#define endl "\n"
#define fi first
#define se second
const int M=1e9+7;
const int inf = 1e14;
const int LOG=17;
const int N=1e5+5;
int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r;
map<pair<int,int>,pair<int,int>>p;
map<int,vector<int>>a;
int gl;
pair<int,int> get(int x,int y){
auto it=lower_bound(a[x].begin(),a[x].end(),y);
if (it==a[x].end() or x==gl){
return {x,y};
}
else{
return p[{x,y}]=get(x+1,*it);
}
}
void solve(){
cin >> m >> k >> n;
set<int>l;
for (int i=0;i<n;i++){
cin >> x >> y;
a[x].push_back(y);
l.insert(x);
p[{x,y}]={x,y};
}
for (int i:l){
sort(a[i].begin(),a[i].end());
}
cin >> q;
vector<pair<pair<int,int>,pair<int,int>>>v(q);
map<pair<pair<int,int>,pair<int,int>>,queue<int>>in;
vector<string>ans(q);
for (int i=0;i<q;i++){
int x1,y1,x2,y2;
cin >> x1 >> y1 >> x2 >> y2;
v[i]={{x2,x1},{y1,y2}};
in[v[i]].push(i);
}
sort(v.begin(),v.end());
for (int i=0;i<q;i++){
int x1,y1,x2,y2;
x2=v[i].fi.fi;
x1=v[i].fi.se;
y1=v[i].se.fi;
y2=v[i].se.se;
if (x1==x2){
if (y2>=y1){
ans[in[{{x2,x1},{y1,y2}}].front()]="Yes";
in[{{x2,x1},{y1,y2}}].pop();
}
else{
ans[in[{{x2,x1},{y1,y2}}].front()]="No";
in[{{x2,x1},{y1,y2}}].pop();
}
continue;
}
auto it=lower_bound(a[x1].begin(),a[x1].end(),y1);
if (it==a[x1].end()){
ans[in[{{x2,x1},{y1,y2}}].front()]="No";
in[{{x2,x1},{y1,y2}}].pop();
continue;
}
gl=x2;
auto o=get(p[{x1,*it}].fi,p[{x1,*it}].se);
if (o.fi==x2 and o.se<=y2){
ans[in[{{x2,x1},{y1,y2}}].front()]="Yes";
in[{{x2,x1},{y1,y2}}].pop();
}
else{
ans[in[{{x2,x1},{y1,y2}}].front()]="No";
in[{{x2,x1},{y1,y2}}].pop();
}
}
for (int i=0;i<q;i++){
cout << ans[i] << endl;
}
}
signed main()
{
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r" ,stdin);
// freopen("output.txt","w",stdout);
// #endif
ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE
cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE
cout << fixed << setprecision(9);
srand(time(0));
// int t=1;
// cin >> t;
for (int _=1;_<=t;_++){
solve();
q++;
}
}
| # | 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... |