Submission #559742

#TimeUsernameProblemLanguageResultExecution timeMemory
559742slimeTrampoline (info1cup20_trampoline)C++14
11 / 100
703 ms37428 KiB
#include "bits/stdc++.h" using namespace std; #ifdef ONLINE_JUDGE const int MAXN = 2e5 + 10; #endif #ifndef ONLINE_JUDGE const int MAXN = 1029; #endif const int MOD = 1e9 + 7; #define ll __int128 mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } ll read() { int x; cin >> x; return (ll)x; } long long bm(long long b, long long p) { if(p==0) return 1 % MOD; long long r = bm(b, p >> 1); if(p&1) return (((r*r) % MOD) * b) % MOD; return (r*r) % MOD; } long long inv(long long b) { return bm(b, MOD-2); } long long f[MAXN]; long long nCr(int n, int r) { long long ans = f[n]; ans *= inv(f[r]); ans %= MOD; ans *= inv(f[n-r]); ans %= MOD; return ans; } void precomp() { for(int i=0; i<MAXN; i++) f[i] = (i == 0 ? 1 % MOD : (f[i-1] * i) % MOD); } int fastlog(int x) { return (x == 0 ? -1 : 32 - __builtin_clz(x) - 1); } void gay(int i) { cout << "Case #" << i << ": "; } void solve(int tc) { int r, c, n; cin >> r >> c >> n; map<int, set<pair<int, int> > > mp; int a[n], b[n]; for(int i=0; i<n; i++) { cin >> a[i] >> b[i]; mp[a[i]].insert({b[i], i}); mp[a[i]].insert({2e9, -1}); mp[a[i] + 1].insert({2e9, -1}); } int st[18][n]; for(int i=0; i<n; i++) { st[0][i] = (*mp[a[i] + 1].lower_bound({b[i], -1})).second; } for(int i=1; i<18; i++) { for(int j=0; j<n; j++) { st[i][j] = (st[i-1][j] == -1 ? -1 : st[i-1][st[i-1][j]]); } } int t; cin >> t; while(t--) { int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; if(xs == xt && ys <= yt) { cout << "Yes\n"; continue; } else if(xs == xt) { cout << "No\n"; continue; } int d = xt - xs - 1; int g = (*mp[xs].lower_bound({ys, -1})).second; if(g == -1) { cout << "No\n"; continue; } bool done = 0; for(int i=17; i>=0; i--) { if(d >= (1<<i)) { d -= (1<<i); g = st[i][g]; if(g == -1) { cout << "No\n"; done = 1; continue; } } } if(!done) { if(b[g] <= yt) cout << "Yes\n"; else cout << "No\n"; } } } int32_t main() { precomp(); ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for(int i=1; i<=t; i++) solve(i); } // I don't know geometry. // n = 13, k = 3: 0000001010000 // n = 13, k = 5: 0000010001000 // n = 13, k = 7: 0001000100010 // if k < n/2 and n odd: 1[010...10]111...1
#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...