제출 #1332738

#제출 시각아이디문제언어결과실행 시간메모리
1332738al95ireyizTrampoline (info1cup20_trampoline)C++20
100 / 100
789 ms76248 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define len(x) (ll)x.size()
const ll inf = 1e9, infl = 1e18;
const ll MOD = 1e9 + 7;
const ll maxn = 2e5 + 5;
ll n, m, k = 0;

const ll lg = 25;
array<ll, 3> p[maxn];
array<ll, 2> st, en;
ll up[maxn][lg];
map<ll, set<array<ll, 2>>> mp;
ll f(ll x, ll y){
  // ele en sagdaki green trampolin ki, (x, y)-den solda yerlesir
  auto it = mp[x].upper_bound({y, inf});
  if(mp[x].empty() or it == mp[x].begin()) return 0;
  it --;
  return (*it)[1];
}
void _() {
  cin >> n >> m >> k;
  for(ll tt = 1; tt <= k; tt ++){
    cin >> p[tt][0] >> p[tt][1];
    p[tt][0] ++;
    p[tt][2] = tt;
    mp[p[tt][0]].insert({p[tt][1], tt});
  }
  for(ll i = 1; i <= k; i ++){
    up[p[i][2]][0] = f(p[i][0] - 1, p[i][1]);
  }
  for(ll j = 1; j < lg; j ++){
    for(ll i = 1; i <= k; i ++){
      up[i][j] = up[up[i][j - 1]][j - 1];
    }
  }
  auto go = [&](ll x, ll y) -> ll{
    for(ll i = 0; i < lg; i ++){
      if(y & (1ll << i)){
        x = up[x][i];
      }
    }
    return x;
  };
  ll kk;
  cin >> kk;
  for(ll tt = 1; tt <= kk; tt ++){
    cin >> st[0] >> st[1] >> en[0] >> en[1];
    if(st[0] > en[0] or st[1] > en[1]){
      cout << "No\n";
      continue;
    }
    if(st[0] == en[0]){
      cout << "Yes\n";
      continue;
    }
    ll id = f(en[0], en[1]);
    if(id == 0){
      cout << "No\n";
      continue;
    }
    ll dest = go(id, en[0] - st[0] - 1);
    // cout << dest << ' ';
    if(p[dest][1] >= st[1]){
      cout << "Yes\n";
    } else{
      cout << "No\n";
    }
  }
}
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  ll t = 1;
  // cin >> t;
  while(t --) _();
}
#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...