Submission #387607

#TimeUsernameProblemLanguageResultExecution timeMemory
3876072qbingxuanTrampoline (info1cup20_trampoline)C++14
0 / 100
539 ms71016 KiB
#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); } 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 = [&x, &to, &y](int i, int limx) { for (int L = LG-1; L >= 0; L--) { if (x[to[i][i]] <= limx) i = to[i][L]; } return y[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(destx <= 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 y = go(it->second, destx-1); answer (y <= desty); } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...