/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option
#include<bits/stdc++.h>
using namespace std;
#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define ld long double
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 300005;
const ll oo = 1e18 + 7;
int n, a[maxN];
int x, y, z, k;
map<int, vii> mp;
int jp[maxN][32];
int h[maxN], pl[maxN];
signed main(){
// freopen(".inp", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> x >> x >> n;
for1(i, 1, n){
cin >> x >> y;
mp[x].pb(ii(y, i));
h[i] = x;
pl[i] = y;
}
memset(jp, 0, sizeof(jp));
for(auto &pr : mp){
if(mp.find(pr.fi + 1) == mp.end()) continue;
vii &cac = mp[pr.fi + 1];
for(ii cc : pr.se){
int id = lower_bound(all(cac), ii(cc.fi, -oo))
- cac.begin();
if(id == cac.size()) continue;
jp[cc.se][0] = cac[id].se;
}
}
for1(ds, 0, 25){
for1(i, 0, n){
jp[i][ds + 1] = jp[jp[i][ds]][ds];
}
}
int o; cin >> o; while(o--){
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if(x1 >= x2){
if(y1 <= y2 && x1 == x2) cout << "Yes\n";
else cout << "No\n";
continue;
}
vii &cac = mp[x1];
int id = lower_bound(all(cac), ii(y1, -oo)) - cac.begin();
if(id == cac.size()){
cout << "No\n"; continue;
}
id = cac[id].se;
int mask = x2 - x1 - 1;
for2(i, 25, 0) if(mask & (1 << i)){
id = jp[id][i];
}
if(id && pl[id] <= y2) cout << "Yes\n";
else cout << "No\n";
// cout << id << endl;
}
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:56:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | if(id == cac.size()) continue;
| ~~~^~~~~~~~~~~~~
trampoline.cpp:75:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | if(id == cac.size()){
| ~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
75852 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
153 ms |
84552 KB |
expected YES, found NO [3rd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
211 ms |
83660 KB |
expected YES, found NO [4th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
75668 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
446 ms |
90844 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |