#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);
}
}
if (nod==0) return 1000000000;
return s[nod].second;
}
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 |
Correct |
3 ms |
1100 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
3 ms |
1284 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
1100 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
17452 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
70 ms |
19348 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
66 ms |
19056 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
70 ms |
19296 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
18244 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
193 ms |
29880 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
202 ms |
29800 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
191 ms |
29892 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
194 ms |
29896 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
195 ms |
29688 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
844 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
5 ms |
1100 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Incorrect |
7 ms |
1100 KB |
expected NO, found YES [3685th token] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
243 ms |
18252 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
261 ms |
29964 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
202 ms |
30016 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
264 ms |
29800 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
222 ms |
29860 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
218 ms |
29888 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
217 ms |
29908 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
200 ms |
29892 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
244 ms |
29828 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
290 ms |
30004 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
273 ms |
29820 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
183 ms |
30052 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
185 ms |
29944 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
218 ms |
30064 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
194 ms |
29884 KB |
200000 token(s): yes count is 129674, no count is 70326 |