Submission #493902

#TimeUsernameProblemLanguageResultExecution timeMemory
493902balbitTrampoline (info1cup20_trampoline)C++14
11 / 100
592 ms30668 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define pii pair<ll, ll> #define REP(i,n) for (int i = 0; i<n; ++i) #define REP1(i,n) for (int i = 1; i<=n; ++i) #define MX(a,b) a = max(a,b) #define MN(a,b) a = min(a,b) #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #define pb push_back #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__) template<typename T> void _do( T && x) {cerr<<x<<endl;} template<typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);} #else #define bug(...) #define endl '\n' #endif // BALBIT const int maxn = 2e5+5; int row[maxn], col[maxn]; int nxt[20][maxn]; map<int, vector<pii> > mp; // the vectors store {col, index} signed main(){ ios::sync_with_stdio(0), cin.tie(0); bug(1,2); int R,C; cin>>R>>C; int n; cin>>n; REP(i,n) { int r, c; cin>>r>>c; mp[r].pb({c, i}); row[i] = r; col[i] = c; } nxt[0][n] = n; row[n] = R+1; col[n] = C+1; for (auto &u : mp) { sort(ALL(u.s)); for (pii p : u.s) { auto it = lower_bound(ALL(mp[u.f+1]), pii{p.f, -1}); if (it == mp[u.f+1].end()) { nxt[0][p.s] = n; }else{ nxt[0][p.s] = it->s; } } } for (int j = 1; j<20; ++j) { REP(i,n+1) { nxt[j][i] = nxt[j-1][nxt[j-1][i]]; } } int q; cin>>q; while (q--) { ll Rs, Cs, Re, Ce; cin>>Rs>>Cs>>Re>>Ce; if (Re < Rs || Ce < Cs) { bug("bruh"); cout<<"No"<<endl; continue; } if (Re == Rs) { bug("same row..."); cout<<"Yes"<<endl; continue; } if (!mp.count(Rs)) { bug("no available down"); cout<<"No"<<endl; continue; } auto it = lower_bound(ALL(mp[Rs]), make_pair(Cs, -1ll)); int who = (it==mp[Rs].end())?(n) : it->s; if (it != mp[Rs].end()) bug(it->f, it->s); for (int i = 19; i>=0; --i) { int ty = nxt[i][who]; if (ty != n && row[ty] < Re) { who = nxt[i][who]; } } if (who!=n && row[who] == Re-1 && col[who] <= Ce) { cout<<"Yes"<<endl; }else{ bug("Sorry! Toof ar!"); cout<<"No"<<endl; } } }
#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...