This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |