Submission #559742

# Submission time Handle Problem Language Result Execution time Memory
559742 2022-05-10T13:29:49 Z slime Trampoline (info1cup20_trampoline) C++14
11 / 100
703 ms 37428 KB
#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 time Memory Grader output
1 Incorrect 6 ms 1364 KB expected NO, found YES [28th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 231 ms 25636 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 368 ms 26168 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 370 ms 26028 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 399 ms 26168 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 403 ms 26408 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 412 ms 26376 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 596 ms 35448 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 980 KB expected NO, found YES [17th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 703 ms 37428 KB expected NO, found YES [37th token]
2 Halted 0 ms 0 KB -