#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
const int L = 20;
const int INF = (int)1e9 + 123;
int R, C, n;
pair<int, int> green[N];
int a[N], b[N];
int go[L][N];
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cin >> R >> C >> n;
for (int i = 0; i < n; ++i)
cin >> green[i].second >> green[i].first;
green[n] = {INF, INF};
sort(green, green + n);
for (int i = 0; i < n; ++i)
a[i] = green[i].second, b[i] = green[i].first;
for (int i = 0; i <= n; ++i)
go[0][i] = n;
map<int, int> last;
for (int i = n - 1; i >= 0; --i) {
if (last.find(a[i] + 1) != last.end())
go[0][i] = last[a[i] + 1];
last[a[i]] = i;
}
map<int, vector<pair<int, int>>> for_x;
for (int i = 0; i < n; ++i)
for_x[a[i]].emplace_back(b[i], i);
int t;
cin >> t;
while (t--) {
int xstart, ystart, xstop, ystop;
cin >> xstart >> ystart >> xstop >> ystop;
if (xstart > xstop || ystart > ystop) {
cout << "No\n";
} else if (xstart == xstop) {
cout << "Yes\n";
} else {
auto it = lower_bound(for_x[xstart].begin(), for_x[xstart].end(), make_pair(ystart, INF));
if (it == for_x[xstart].end() || it->first > ystop) {
cout << "No\n";
} else {
int pos = it->second;
for (int i = L - 1; i >= 0; --i) {
if (b[go[i][pos]] <= ystop)
pos = go[i][pos];
}
if (a[pos] + 1 >= xstop)
cout << "Yes\n";
else
cout << "No\n";
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
748 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
2540 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
25 ms |
4204 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
908 KB |
expected YES, found NO [10th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
26 ms |
4204 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |