Submission #1145616

#TimeUsernameProblemLanguageResultExecution timeMemory
1145616saidponTrampoline (info1cup20_trampoline)C++20
0 / 100
111 ms5084 KiB
#include <bits/stdc++.h> #define nemeshay ios_base::sync_with_stdio(NULL), cin.tie(0), cout.tie(0); #define int long long #define sigma signed #define pb push_back #define fr first #define sc second #define pii pair<int, int> #define double long double #define YES cout << "YES" << endl #define NO cout << "NO" << endl #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define OK cout << "OK" << endl #define Ok cout << "Ok" << endl #define nosolve cout << "-1" << endl using namespace std; const int N = 2e5 + 2, inf = 1e18 + 7, mod = 998244353; pii a[N]; int used[N], p[N], anc[20][N]; sigma main() { int R, C, n; cin >> R >> C >> n; for (int i = 1; i <= n; i++) cin >> a[i].fr >> a[i].sc; sort (a + 1, a + n + 1); for (int i = n; i > 0; i--) { auto check = [&](int ind) { return a[i].fr - a[ind].fr > 1 || (a[i].fr - a[ind].fr == 1 && a[ind].sc <= a[i].sc); }; int l = 1, r = i - 1; while (r - l > 1) { int m = l + r >> 1; if (check(m)) l = m; else r = m; } if (a[i].fr - a[r].fr == 1 && a[r].sc <= a[i].sc) p[r] = i; else if (a[i].fr - a[l].fr == 1 && a[l].sc <= a[i].sc) p[l] = i; } for (int i = 1; i <= n; i++) { if (used[i]) continue; int x = p[i], prev = i; while (x) { used[x] = 1; anc[x][0] = prev; for (int j = 1; j < 20; j++) anc[x][j] = anc[anc[x][j - 1]][j - 1]; prev = x, x = p[x]; } } int q; cin >> q; while (q--) { int xs, ys, xf, yf; cin >> xs >> ys >> xf >> yf; if (xs > xf || ys > yf) { No; continue; } if (xs == xf) { Yes; continue; } xf--; auto check = [&](int ind) { return a[ind].fr < xf || (a[ind].fr == xf && a[ind].sc <= yf); }; int l = 1, r = n, ind = 0; while (r - l > 1) { int m = l + r >> 1; if (check(m)) l = m; else r = m; } if (check(r)) ind = r; else if (check(l)) ind = l; if (!ind || xf != a[ind].fr) { No; continue; } for (int i = 0; i < 20; i++) if ((xf - xs) & (1 << i)) ind = anc[ind][i]; if (!ind || a[ind].sc < ys) No; else Yes; } }
#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...