#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 6000006
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sz(s) (int)s.size()
#define pii pair<int,int>
ll T, n, a[N], inx, r, c, b[5];
map <int,vector <int>> vis;
vector <int> v;
set <int> s;
map <pair<ll,ll>,int> vip;
int main () {
ios::sync_with_stdio(0);cin.tie(0);
cin >> r >> c >> n;
for(int i = 1; i <= n; i++) {
int x, y;
cin >> x >> y;
vip[{x,y}] = 1;
s.insert(x);
vis[x].pb(y);
}
for(auto i:s) {
v.pb(i);
sort(vis[i].begin(),vis[i].end());
}
cin >> T;
for(int i = 1; i <= T; i++) {
int x, y, w, f;
cin >> x >> y >> w >> f;
if(x > w || y > f) {
cout << "No\n";
continue;
}
if(x == w) {
cout << "Yes\n";
continue;
}
int pos1 = lower_bound(v.begin(),v.end(),x) - v.begin();
int pos2 = lower_bound(v.begin(),v.end(),w-1) - v.begin();
if(pos1 == sz(v) || pos2 == sz(v) || pos2 - pos1 + 1 != (w-1)-x + 1) {
cout << "No\n";
continue;
}
bool tr = 0;
while(x != w) {
if(!sz(vis[x]) || vis[x][sz(vis[x]) - 1] < y) {
tr = 1;
break;
}
int p = *lower_bound(vis[x].begin(),vis[x].end(),y);
if(p > f) {
tr = 1;
break;
}
x++;
y = p;
}
if(tr) cout << "No\n";
else cout << "Yes\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... |