#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) {
cout << "Yes\n";
continue;
}
if (x1 > x2) {
cout << "No\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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1584 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
8 ms |
1696 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
239 ms |
28996 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
230 ms |
28996 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
239 ms |
28444 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
234 ms |
29016 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
446 ms |
39236 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
478 ms |
39364 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
504 ms |
39348 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
538 ms |
39572 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
586 ms |
39492 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
621 ms |
45380 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1228 KB |
expected NO, found YES [16th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
810 ms |
46800 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Incorrect |
703 ms |
41112 KB |
expected NO, found YES [22020th token] |
3 |
Halted |
0 ms |
0 KB |
- |