#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
const int L = 20;
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] = {C + 1, R + 1};
sort(green, green + n + 1);
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;
}
for (int p = 1; p < L; ++p) {
for (int i = 0; i <= n; ++i)
go[p][i] = go[p - 1][go[p - 1][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, 0));
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1388 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
6 ms |
1644 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
4 ms |
1260 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1516 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
2028 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1004 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
1260 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
11 ms |
2028 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
7 ms |
1260 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
9 ms |
1516 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
7 ms |
1260 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
2284 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |