// #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;
for (int i=0;i<q;i++){
int x1,y1,x2,y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1==x2){
if (y2>=y1){
cout << "Yes" << endl;
}
else{
cout << "No" << endl;
}
continue;
}
gl=x2;
auto o=get(x1,y1);
if (o.fi==x2 and o.se<=y2){
cout << "Yes" << endl;
}
else{
cout << "No" << 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... |