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;
void solve() {
int r, c;
cin >> r >> c;
int n;
cin >> n;
map <int, vector <int>> mp;
for(int i = 0; i < n; i ++) {
int a, b;
cin >> a >> b;
a --;
b --;
#define pb push_back
mp[a].pb(b);
}
int T;
cin >> T;
while(T --) {
pair <int, int> start, end;
cin >> start.first >> start.second >> end.first >> end.second;
start.first --;
start.second --;
end.first --;
end.second --;
int x1 = start.first;
int y1 = start.second;
int x2 = end.first;
int y2 = end.second;
while(x1 != x2) {
if(mp[x1].empty()) break;
auto temp = lower_bound(mp[x1].begin(), mp[x1].end(), y1);
if(temp == mp[x1].end()) break;
y1 = *temp; x1 ++;
}
if(x1 == x2 and y1 <= y2) cout << "Yes\n";
else cout << "No\n";
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int Q = 1;
//cin >> Q;
while (Q --) {
solve();
}
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... |