Submission #481784

#TimeUsernameProblemLanguageResultExecution timeMemory
481784Yazan_AlattarTrampoline (info1cup20_trampoline)C++14
0 / 100
240 ms27632 KiB
#include <iostream> #include <fstream> #include <vector> #include <cstring> #include <algorithm> #include <set> #include <map> #include <queue> #include <list> #include <utility> #include <cmath> #include <numeric> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 200007; const ll inf = 1e18; const ll mod = 1e9 + 7; const double pi = acos(-1); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; set < pair < pair < int,int >, int > > s; pair <int,int> a[M]; int r, c, n, nxt[M][22]; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> r >> c >> n; for(int i = 1; i <= n; ++i) cin >> a[i].F >> a[i].S; sort(a + 1, a + n + 1); for(int i = 1; i <= n; ++i){ while(s.size()){ pair < pair <int,int>, int > p = *s.begin(); if(p.F.F + 1 < a[i].F) s.erase(s.begin()); else if(p.F.F == a[i].F - 1 && p.F.S <= a[i].S){ nxt[p.S][0] = i; s.erase(s.begin()); } else break; } s.insert({a[i], i}); } for(int j = 1; j <= 20; ++j) for(int i = 1; i <= n; ++i) nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; int q; cin >> q; while(q--){ pair <int,int> st, en; cin >> st.F >> st.S >> en.F >> en.S; // if(st.F == en.F){ // if(st.S <= en.S) cout << "Yes\n"; // else cout << "No\n"; // continue; // } int x = lower_bound(a + 1, a + n + 1, st) - a; if(x <= n && a[x].S <= en.S) cout << "Yes\n"; else cout << "No\n"; // if(x > n || a[x].F > st.F){ // cout << "No\n"; // continue; // } // for(int i = 20; i >= 0; --i) // if(nxt[x][i] && a[nxt[x][i]].F <= en.F) x = nxt[x][i]; // if((a[x].F == en.F || a[x].F + 1 == en.F) && a[x].S <= en.S) cout << "Yes\n"; // else cout << "No\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...