Submission #922317

#TimeUsernameProblemLanguageResultExecution timeMemory
922317maxFedorchukTrampoline (info1cup20_trampoline)C++17
0 / 100
515 ms77804 KiB
#include "bits/stdc++.h" using namespace std; const long long MX=5e5+100; vector < pair < long long , long long > > mas[MX]; set < pair < long long , long long > > ab; vector < long long > reb[MX]; map < long long , long long > as; long long r,c,n; long long uk=0,nm=0; void cnt() { for (auto u: ab) { as[u.first - 1]++; as[u.first]++; as[u.first + 1]++; } for (auto &u: as) { uk++; u.second = uk; } for (auto u: ab) { nm++; mas[as[u.first]].push_back({u.second, nm}); } for (long long i = 1; i <= uk; i++) { nm++; mas[i].push_back({c + 1, nm}); } } long long tin[MX],tou[MX]; long long timer=0; void DFS(long long zar) { timer++; tin[zar] = timer; for (auto u: reb[zar]) { DFS(u); } timer++; tou[zar] = timer; } void cnt2() { for (long long i = 1; i < uk; i++) { for (auto u: mas[i]) { long long frm = (*lower_bound(mas[i + 1].begin(), mas[i + 1].end(), make_pair(u.first, 0LL))).second; reb[frm].push_back(u.second); } } DFS(mas[uk][0].second); } void zap() { long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 >= x2) { cout << (((y1 <= y2) && (x1 == x2)) ? "Yes" : "No") << "\n"; return; } if (as.find(x1) == as.end() || as.find(x2 - 1) == as.end()) { cout << "No\n"; return; } long long rlx1 = as[x1], rlx2 = as[x2 - 1]; if (y2 < mas[rlx2][0].first) { cout << "No\n"; } pair<long long, long long> frb = (*lower_bound(mas[rlx1].begin(), mas[rlx1].end(), make_pair(y1, 0LL))); pair<long long, long long> srb = (*(upper_bound(mas[rlx2].begin(), mas[rlx2].end(), make_pair(y2, 0LL))--)); if (tin[mas[rlx2][0].second] <= tin[frb.second] && tou[frb.second] <= tou[srb.second]) { cout << "Yes\n"; } else { cout << "No\n"; } } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> r >> c >> n; long long a, b; for (long long i = 1; i <= n; i++) { cin >> a >> b; ab.insert({a, b}); } cnt(); cnt2(); long long q; cin >> q; while (q--) { zap(); } return 0; }
#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...