#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
map<int, set<pair<int, int>>> trampolines;
int a[200001], b[200001], nxt[200001][20];
int main() {
cin.tie(0)->sync_with_stdio(0);
int r, c, n;
cin >> r >> c >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
trampolines[-a[i]].insert({b[i], i});
}
for (auto &i : trampolines) {
for (pair<int, int> j : i.second) {
auto lb = trampolines[i.first - 1].lower_bound({j.first, 0});
if (lb != trampolines[i.first - 1].end()) {
nxt[j.second][0] = lb->second;
for (int k = 1; k < 20; k++)
nxt[j.second][k] = nxt[nxt[j.second][k - 1]][k - 1];
}
}
}
int t;
cin >> t;
while (t--) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2 || y1 > y2) {
cout << "No\n";
continue;
}
if (x1 == x2) {
cout << "Yes\n";
continue;
}
auto lb = trampolines[-x1].lower_bound({y1, 0});
if (lb == trampolines[-x1].end()) {
cout << "No\n";
continue;
}
int rem = x2 - x1 - 1;
int curr = lb->second;
for (int i = 0; i < 20; i++) if (rem & (1 << i))
curr = nxt[curr][i];
if (curr && b[curr] <= y2) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1484 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
7 ms |
1740 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
5 ms |
1228 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
304 ms |
27524 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
296 ms |
27524 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
309 ms |
27344 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
304 ms |
27536 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
514 ms |
27972 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
535 ms |
27980 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
495 ms |
27920 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
504 ms |
28172 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
528 ms |
28132 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
593 ms |
34180 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1228 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
1228 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
9 ms |
1868 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
9 ms |
1228 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
10 ms |
1356 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
7 ms |
1304 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
802 ms |
35592 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
679 ms |
29924 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
515 ms |
39364 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1062 ms |
58064 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
723 ms |
45956 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
633 ms |
39364 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
614 ms |
39416 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
589 ms |
39312 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
840 ms |
45528 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
898 ms |
45508 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
988 ms |
51780 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
559 ms |
39324 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
551 ms |
39396 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
676 ms |
39416 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
586 ms |
39272 KB |
200000 token(s): yes count is 129674, no count is 70326 |