#include "bits/stdc++.h"
using namespace std;
#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ss second
#define ff first
#define pb push_back
void solve(){
int r, c, n; cin >> r >> c >> n;
map<int, set<int>> xy;
vector<int> comp;
for(int i = 0; i < n; i++){
int a, b; cin >> a >> b;
xy[a].insert(b);
comp.pb(a);
}
sort(all(comp));
vector<set<int>> nw(n);
for(int i = 0; i < n; i ++){
nw[i] = xy[comp[i]];
}
auto ans = [&](int x, int y, int xx, int yy) -> bool{
if(x > xx || y > yy) return false;
if(x == xx) return true;
int a = lower_bound(all(comp), x) - comp.begin();
int b = lower_bound(all(comp), xx) - comp.begin();
if(comp[a] != x) return false;
if(xx - x > b - a) return false;
for(; a < b; a++){
if(nw[a].empty()) return false;
auto it = nw[a].lower_bound(y);
if(it == nw[a].end()) return false;
if(*it > yy) return false;
y = *it;
}
return true;
};
int t; cin >> t;
while(t--){
int x, y, xx, yy; cin >> x >> y >> xx >> yy;
cout << (ans(x, y, xx, yy) ? "Yes" : "No") << endl;
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1; //cin >> t;
while(t--){
solve();
cout << endl;
}
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... |