Submission #1133865

#TimeUsernameProblemLanguageResultExecution timeMemory
1133865huoiTrampoline (info1cup20_trampoline)C++17
54 / 100
396 ms36424 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 9e18 #define N 200005 void solve() { int r, c, n; cin >> r >> c >> n; vector<pair<int, int>> green(n); for (int i = 0; i < n; i++) { cin >> green[i].first >> green[i].second; } sort(green.begin(), green.end()); vector<vector<int>> up(20, vector<int>(n, -1)); for (int i = 0; i < n; i++) { auto it = lower_bound(green.begin(), green.end(), make_pair(green[i].first + 1, green[i].second)); if (it == green.end()) continue; int ni = it - green.begin(); if (green[ni].first != green[i].first + 1) continue; up[0][i] = it - green.begin(); } for (int k = 1; k < 20; k++) { for (int i = 0; i < n; i++) { if (up[k - 1][i] != -1) { up[k][i] = up[k - 1][up[k - 1][i]]; } } } int q; cin >> q; while (q--) { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; if (r1 > r2) { cout << "No\n"; continue; } auto it = lower_bound(green.begin(), green.end(), make_pair(r1, c1)); if (it == green.end() || it->first > r1) { if (r1 == r2 && c1 <= c2) cout << "Yes\n"; else cout << "No\n"; continue; } int i = it - green.begin(); for (int k = 19; k >= 0; k--) { if (up[k][i] == -1) continue; int ni = up[k][i]; if (green[ni].first < r2) { i = ni; } } cout << (((green[i].first == r2 || green[i].first == r2 - 1) && green[i].second <= c2) ? "Yes\n" : "No\n"); } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); 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...