제출 #1318470

#제출 시각아이디문제언어결과실행 시간메모리
1318470Ghulam_JunaidTrampoline (info1cup20_trampoline)C++20
11 / 100
993 ms355068 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, SQ = 450; int n, m, g, q; int par[N][SQ]; vector<pair<int, int>> vec; int main(){ cin >> n >> m >> g; for (int i = 0; i < g; i ++){ int x, y; cin >> x >> y; vec.push_back({x, y}); } sort(vec.begin(), vec.end()); for (int i = 0; i < g; i ++){ auto [x, y] = vec[i]; x++; par[i][0] = i; int lb = lower_bound(vec.begin(), vec.end(), (pair<int, int>){x, y}) - vec.begin(); if (lb != vec.size() and vec[lb].first == x) par[i][0] = lb; } for (int i = g - 1; i >= 0; i--) for (int j = 1; j < SQ; j ++) par[i][j] = par[par[i][j - 1]][j - 1]; cin >> q; while (q--){ int sx, sy, ex, ey; cin >> sx >> sy >> ex >> ey; if (sx == ex){ if (sy <= ey) cout << "Yes\n"; else cout << "No\n"; continue; } int i = lower_bound(vec.begin(), vec.end(), (pair<int, int>){sx, sy}) - vec.begin(); if (i == vec.size() or vec[i].first != sx){ cout << "No\n"; continue; } while (vec[i].first + 1 < ex){ int d = ex - vec[i].first - 1; if (d <= SQ){ i = par[i][d - 1]; break; } int prv = i; i = par[i][SQ - 1]; if (i == prv) break; } if (vec[i].first + 1 != ex){ cout << "No\n"; continue; } if (vec[i].second <= ey) cout << "Yes\n"; else cout << "No\n"; } }
#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...