Submission #1086817

#TimeUsernameProblemLanguageResultExecution timeMemory
1086817LOLOLOTrampoline (info1cup20_trampoline)C++14
100 / 100
451 ms58164 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define s second #define f first #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (int)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) #define len(x) (int)(x.length()) const int N = 2e5 + 10; map <int, set <pair <int, int>>> mp; int nxt[N][20]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int r, c, n; cin >> r >> c >> n; vector <pair <int, int>> save; save.pb({-1, -1}); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; save.pb({a, b}); } sort(all(save)); for (int i = 1; i < sz(save); i++) { mp[save[i].f].insert({save[i].s, i}); } for (int i = sz(save) - 1; i >= 1; i--) { int x = save[i].f, y = save[i].s; auto T = mp[x + 1].lower_bound({y, 0}); if (T == mp[x + 1].end()) continue; nxt[i][0] = T -> s; for (int j = 1; j < 20; j++) nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; } int t; cin >> t; while (t--) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 > x2 || y1 > y2) { cout << "No\n"; continue; } if (x2 == x1) { cout << "Yes\n"; continue; } auto it = mp[x1].lower_bound({y1, 0}); if (it == mp[x1].end()) { cout << "No\n"; continue; } int len = x2 - x1 - 1, st = it -> s; for (int j = 0; j < 20; j++) { if (len & (1 << j)) { st = nxt[st][j]; } } if (st == 0 || save[st].s > y2) { cout << "No\n"; } else { cout << "Yes\n"; } } 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...