#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
const int N = 200100;
const int oo = 2e9;
int n, t, nxt[N][22];
map<int, set<ii>> mp;
vector<ii> v, u;
vector<iii> gr;
ii q[N];
bool proc(int u, int v, int x, int y) {
if (u > x) return 0;
if (v > y) return 0;
if (u == x) return 1;
int len = (x - u - 1);
if (!mp.count(u)) return 0;
auto it = mp[u].lower_bound(ii(v, -1));
if (it == mp[u].end()) return 0;
int cur = it->y;
for (int i = 21; i >= 0; --i) if (len >> i & 1) {
cur = nxt[cur][i];
if (cur == oo) return 0;
}
return q[cur].y <= y;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> n >> n;
for (int a, b, i = 1; i <= n; ++i) {
cin >> a >> b;
q[i] = ii(a, b);
mp[a].insert(ii(b, i));
gr.push_back(iii(ii(a, b), i));
}
sort(gr.begin(), gr.end(), [](const iii& a, const iii& b) {
return (a.x.x < b.x.x || (a.x.x == b.x.x && a.x.y < b.x.y));
});
int pre = oo;
for (int i = n - 1; i >= 0; --i) {
int a = gr[i].x.x, b = gr[i].x.y, id = gr[i].y;
nxt[id][0] = oo;
if (a + 1 == pre) {
v = u;
sort(v.begin(), v.end());
u.clear();
} else if (a < pre) {
v.clear();
u.clear();
}
if (!v.empty()) {
auto it = lower_bound(v.begin(), v.end(), ii(b, -1));
if (it != v.end()) {
nxt[id][0] = it->y;
}
}
u.push_back(ii(b, id));
pre = a;
}
for (int j = 1; j < 22; ++j) {
for (int i = 1; i <= n; ++i) if (nxt[i][j - 1] != oo) {
nxt[i][j] = nxt[ nxt[i][j - 1] ][j - 1];
} else nxt[i][j] = oo;
}
cin >> t;
for (int u, v, x, y, i = 1; i <= t; ++i) {
cin >> u >> v >> x >> y;
cout << (proc(u, v, x, y) ? "Yes" : "No") << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1792 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
7 ms |
2176 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
5 ms |
1536 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
31136 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
253 ms |
33088 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
260 ms |
32544 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
247 ms |
33060 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
456 ms |
34468 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
467 ms |
33444 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
481 ms |
32036 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
534 ms |
31972 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
504 ms |
32040 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
606 ms |
37896 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1152 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
1408 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
9 ms |
1920 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
7 ms |
1536 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
9 ms |
1536 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
7 ms |
1536 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
748 ms |
39328 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
664 ms |
45220 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
505 ms |
43684 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
874 ms |
62244 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
666 ms |
52004 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
533 ms |
45732 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
547 ms |
45456 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
507 ms |
43984 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
733 ms |
49572 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
749 ms |
49700 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
832 ms |
55844 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
483 ms |
45348 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
484 ms |
46244 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
572 ms |
43712 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
483 ms |
44964 KB |
200000 token(s): yes count is 129674, no count is 70326 |