답안 #559747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559747 2022-05-10T13:41:32 Z slime Trampoline (info1cup20_trampoline) C++14
100 / 100
825 ms 87844 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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;
    }
    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;
          break;
        }
      }
    }
    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 Correct 7 ms 2260 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 2516 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 1876 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 333 ms 44480 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 303 ms 44536 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 289 ms 44212 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 262 ms 44552 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 398 ms 44860 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 486 ms 44940 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 549 ms 44760 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 473 ms 45228 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 541 ms 45160 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 630 ms 55288 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1448 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 8 ms 1748 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 3308 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 1748 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 1996 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1748 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 733 ms 57472 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 713 ms 59796 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 569 ms 56620 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 825 ms 87844 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 622 ms 67608 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 515 ms 56560 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 520 ms 56612 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 574 ms 56620 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 798 ms 66968 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 784 ms 67056 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 821 ms 77524 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 447 ms 56676 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 440 ms 56544 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 627 ms 56848 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 504 ms 56632 KB 200000 token(s): yes count is 129674, no count is 70326