#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 200005
#define fi first
#define se second
vector<pair<int,int>> v[lim];
int xm[lim],ym[lim];
map<int,int> mp;
set<int> st;
int timer,l;
int up[lim][35];
int32_t main(){
faster
int r,c,n;cin>>r>>c>>n;
l=ceil(log2(n));
FOR{
cin>>xm[i]>>ym[i];
st.insert(xm[i]);
}
for(auto x:st){
mp[x]=++timer;
}
FOR{
v[mp[xm[i]]].push_back({ym[i],i});
}
for(int i=1;i<=timer;i++){
sort(v[i].begin(),v[i].end());
}
FOR{
if(mp.find(xm[i]+1)==mp.end())continue;
int tut=lower_bound(v[mp[xm[i]+1]].begin(),v[mp[xm[i]+1]].end(),make_pair(ym[i],0ll))-v[mp[xm[i]+1]].begin();
if(tut>=v[mp[xm[i]+1]].size())continue;
up[i][0]=v[mp[xm[i]+1]][tut].se;
}
for(int i=1;i<=l;i++){
for(int node=1;node<=timer;node++){
up[node][i]=up[up[node][i-1]][i-1];
}
}
int q;cin>>q;
while(q--){
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
if(y2<y1){
cout<<"No"<<'\n';
continue;
}
if(x1>x2){
cout<<"No"<<'\n';
continue;
}
if(x1==x2){
if(y1<=y2)cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
continue;
}
if(mp.find(x1)==mp.end() || y1>y2){
if(x1==x2 && y1<=y2)cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
continue;
}
int node=lower_bound(v[mp[x1]].begin(),v[mp[x1]].end(),make_pair(y1,0ll))-v[mp[x1]].begin();
if(node>=v[mp[x1]].size() || v[mp[x1]][node].fi>y2){
cout<<"No"<<'\n';
continue;
}
node=v[mp[x1]][node].se;
for(int i=l;i>=0;i--){
if(!up[node][i] && up[node][i]<x2){
node=up[node][i];
}
}
if(ym[node]<=y2){
cout<<"Yes"<<'\n';
}
else cout<<"No"<<'\n';
}
return 0;
}
Compilation message
trampoline.cpp: In function 'int32_t main()':
trampoline.cpp:52:9: 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]
52 | if(tut>=v[mp[xm[i]+1]].size())continue;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:84:10: 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]
84 | if(node>=v[mp[x1]].size() || v[mp[x1]][node].fi>y2){
| ~~~~^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
13916 KB |
expected NO, found YES [2nd token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
174 ms |
70648 KB |
expected NO, found YES [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
174 ms |
79928 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
171 ms |
79328 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
184 ms |
79292 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
306 ms |
80468 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
280 ms |
80464 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
486 ms |
87888 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
12124 KB |
expected NO, found YES [59th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
533 ms |
89424 KB |
expected NO, found YES [23rd token] |
2 |
Halted |
0 ms |
0 KB |
- |