답안 #559741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559741 2022-05-10T13:28:20 Z slime Trampoline (info1cup20_trampoline) C++14
11 / 100
782 ms 49128 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;
    }
    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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1492 KB expected NO, found YES [28th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 317 ms 27564 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 37900 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 442 ms 37688 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 505 ms 37708 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 569 ms 38140 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 574 ms 38104 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 651 ms 47112 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1284 KB expected NO, found YES [17th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 782 ms 49128 KB expected NO, found YES [37th token]
2 Halted 0 ms 0 KB -