#include <iostream>
#include <algorithm>
using namespace std;
int n,t[25][200005],xs,ys,xf,yf,i,j,test,st;
pair<int,int> s[200005];
int cb(int x,int y)
{
int st=1,dr=n,mij=0,ras=0;
while (st<=dr)
{
mij=(st+dr)/2;
if (s[mij].first>x) {dr=mij-1;}
else if (s[mij].first<x) {st=mij+1;}
else if (s[mij].second<y) {st=mij+1;}
else {dr=mij-1; ras=mij;}
}
return ras;
}
int ascen(int nod,int lvl)
{
for (int i=19;i>=0;--i)
{
if ((1<<i)<=lvl)
{
nod=t[i][nod];
lvl-=(1<<i);
}
}
return nod;
}
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
cin>>n>>n>>n;
for (i=1;i<=n;++i)
{
cin>>s[i].first>>s[i].second;
}
sort(s+1,s+n+1);
for (i=1;i<=n;++i)
{
t[0][i]=cb(s[i].first+1,s[i].second);
}
for (i=1;i<=19;++i)
{
for (j=1;j<=n;++j)
t[i][j]=t[i-1][t[i-1][j]];
}
cin>>test;
for (i=1;i<=test;++i)
{
cin>>xs>>ys>>xf>>yf;
if (xs==xf) {if (ys<=yf) {cout<<"Yes"<<'\n';} else {cout<<"No"<<'\n';} continue;}
if (xf<xs||yf<ys) {cout<<"No"<<'\n'; continue;}
st=cb(xs,ys);
if (st==0) {cout<<"No";}
else if (ascen(st,xf-1-xs)<=yf) {cout<<"Yes";}
else {cout<<"No";}
cout<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1236 KB |
expected YES, found NO [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
68 ms |
19408 KB |
expected NO, found YES [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
25832 KB |
expected NO, found YES [1st token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1104 KB |
expected NO, found YES [59th token] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
281 ms |
25240 KB |
expected NO, found YES [23rd token] |
2 |
Halted |
0 ms |
0 KB |
- |