#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
int cnt = sizeof...(T);
((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
#define pary(a...) danb(#a, a)
template <typename T> void danb(const char *s, T L, T R) {
std::cerr << "\033[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L) std::cerr << (f++ ? " " : "") << *L;
std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back
using namespace std;
const int inf = 1e9, MOD = 1000000007, maxn = 2525, LG = 20;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int R, C, N;
cin >> R >> C >> N;
vector<int> x(N), y(N);
map<int, vector<pair<int,int>>> mp;
for (int i = 0; i < N; i++) {
cin >> x[i] >> y[i];
mp[x[i]].emplace_back(y[i], i);
}
for (auto &[x, ys]: mp)
sort(all(ys));
vector<vector<int>> to(N, vector<int>(LG));
for (int i = 0; i < N; i++) {
if (!mp.count(x[i]+1)) {
to[i][0] = i;
} else {
auto &v = mp[x[i]+1];
auto it = lower_bound(all(v), make_pair(y[i], 0));
if (it == v.end())
to[i][0] = i;
else
to[i][0] = it->second;
}
}
for (int L = 1; L < LG; L++) {
for (int i = 0; i < N; i++) {
to[i][L] = to[to[i][L-1]][L-1];
}
}
auto go = [&](int i, int dx) {
for (int L = LG-1; L >= 0; L--) {
if (dx >> L & 1)
i = to[i][L];
}
return i;
};
auto answer = [](bool f) {
cout << (f ? "Yes\n" : "No\n");
};
int q;
cin >> q;
while (q--) {
int srcx, srcy, destx, desty;
cin >> srcx >> srcy >> destx >> desty;
if (srcx > destx) {
answer(false);
} else if (srcx == destx) {
answer(srcy <= desty);
} else if (!mp.count(srcx)) {
debug("CASE1");
answer(false);
} else {
auto it = lower_bound(all(mp[srcx]), make_pair(srcy, 0));
if (it == mp[srcx].end()) {
debug("CASE2");
answer(false);
} else {
debug("CASE3");
int i = go(it->second, destx - srcx - 1);
debug(x[i], y[i]);
answer (x[i] == destx-1 && y[i] <= desty);
}
}
}
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:34:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
34 | for (auto &[x, ys]: mp)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1484 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
7 ms |
1700 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 |
228 ms |
28188 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
226 ms |
28068 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
212 ms |
27436 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
221 ms |
28176 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
324 ms |
27864 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
326 ms |
27844 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
363 ms |
28084 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
425 ms |
28548 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
417 ms |
28412 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
742 ms |
34576 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
972 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
1032 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
10 ms |
1484 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
972 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
9 ms |
1152 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
7 ms |
972 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1150 ms |
35888 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
785 ms |
30788 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
418 ms |
27980 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
1396 ms |
47944 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
691 ms |
34900 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
428 ms |
27756 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
404 ms |
27652 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
413 ms |
27696 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
1138 ms |
34684 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
1033 ms |
35012 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
1306 ms |
40848 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
330 ms |
27768 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
351 ms |
27832 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
506 ms |
28444 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
371 ms |
27696 KB |
200000 token(s): yes count is 129674, no count is 70326 |