#include "bits/stdc++.h"
using namespace std;
const long long MX=2e5+100;
map < long long , set < pair < long long, long long > >> mp;
long long lca[30][MX];
long long col[MX];
long long r,c,n;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cin >> r >> c >> n;
for (long long i = 1; i <= n; i++) {
long long a, b;
cin >> a >> b;
mp[a].insert({b, i});
col[i] = b;
}
for (auto [zr, st]: mp) {
for (auto [zn, in]: st) {
auto it = mp[zr + 1].lower_bound({zn, 0});
if (it != mp[zr + 1].end()) {
lca[0][in] = (*it).second;
}
}
}
for (long long sl = 1; sl < 30; sl++) {
for (long long i = 1; i <= n; i++) {
lca[sl][i] = lca[sl - 1][lca[sl - 1][i]];
}
}
long long q;
cin >> q;
while (q--) {
long long 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 st = mp[x1].lower_bound(make_pair(y1, 0));
if (st == mp[x1].end()) {
cout << "No\n";
continue;
}
long long rd = x2 - x1 - 1, zr = (*st).second;
for (long long i = 0; i < 30; i++) {
if ((rd >> i) & 1) {
zr = lca[i][zr];
}
}
if (zr != 0 && col[zr] <= y2) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
48220 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
11 ms |
48324 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
10 ms |
48216 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
63564 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
155 ms |
63572 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
144 ms |
63132 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
149 ms |
63828 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
327 ms |
80840 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
344 ms |
78116 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
336 ms |
74324 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
312 ms |
74116 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
303 ms |
74068 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
425 ms |
80100 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
48216 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
12 ms |
48220 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
12 ms |
47196 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
11 ms |
48220 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
12 ms |
48476 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
11 ms |
48476 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
594 ms |
81304 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
520 ms |
75684 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
323 ms |
74420 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
684 ms |
92636 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
494 ms |
86804 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
370 ms |
78140 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
376 ms |
78196 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
352 ms |
75620 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
670 ms |
79952 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
674 ms |
80120 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
709 ms |
86356 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
323 ms |
81588 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
351 ms |
81384 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
417 ms |
73948 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
341 ms |
78144 KB |
200000 token(s): yes count is 129674, no count is 70326 |