#include "bits/stdc++.h"
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ll>pairld;
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
//#define MOD 998244353
#define INF 100000000000007
#define eps 0.0000000001
ll n,m,k,h,g[2*N],p[26][2*N];
struct D{
ll l,r;
}d[2*N];
map<ll,ll>mp;
vector<pairll>v[2*N];
bool mcp(D d1, D d2){
if(d1.l!=d2.l)return d1.l<d2.l;
return d1.r<d2.r;
}
ll P(ll x,ll y){
for(int i=20;i>=0;i--){
ll g=p[i][x];
if(d[g].l<y)x=g;
}
return x;
}
int main(){
cin>>n>>m>>k;
for(int i=1;i<=k;i++){
cin>>d[i].l>>d[i].r;
}
sort(d+1,d+1+k,mcp);
for(int i=1;i<=k;i++){
if(d[i].l!=d[i-1].l){
h++;
g[h]=d[i].l;
mp[d[i].l]=h;
}
v[h].pb({d[i].r,i});
}
for(int i=1;i<=k;i++){
if(mp[d[i].l+1]==0){
p[0][i]=k+1;
}else{
ll l=0;
ll nm=mp[d[i].l+1];
ll r=v[nm].size();
while(l<r){
ll m1=(l+r)/2;
if(v[nm][m1].fr>=d[i].r)r=m1;
else l=m1;
}
if(r==v[nm].size())p[0][i]=k+1;
else p[0][i]=v[nm][r].sc;
}
}
p[0][k+1]=k+1;
for(int i=1;i<=20;i++){
for(int j=1;j<=k+1;j++){
p[i][j]=p[i-1][p[i-1][j]];
}
}
d[k+1].l=INF;
ll q;
cin>>q;
for(int i=1;i<=q;i++){
ll x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
if(x1==x2){
cout<<"Yes"<<endl;
}else{
if(mp[x1]==0){
cout<<"No"<<endl;
continue;
}
ll l=0;
ll nm=mp[x1];
ll r=v[nm].size();
while(l<r){
ll m1=(l+r)/2;
if(v[nm][m1].fr>=y1){
r=m1;
}else l=m1+1;
}
ll h=0;
if(r==v[nm].size())r=k+1;
else h=v[nm][r].sc;
h=P(h,x2);
if(d[h].l==x2-1 && d[h].r<=y2)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return 0;
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:74:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | if(r==v[nm].size())p[0][i]=k+1;
| ~^~~~~~~~~~~~~~
trampoline.cpp:107:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
107 | if(r==v[nm].size())r=k+1;
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2069 ms |
5332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2062 ms |
13276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2061 ms |
12244 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2066 ms |
5204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2072 ms |
18608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |