#include <bits/stdc++.h>
using namespace std;
pair<int,int> a[200005];
int n,i,t,j,sx,sy,fx,fy,r,c,lift[200005][35];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>r>>c>>n;
for(i=1;i<=n;i++)
cin>>a[i].first>>a[i].second;
sort(a+1,a+n+1);
for(i=1;i<=n;i++)
{
int st=i+1;
int dr=n;
int poz=0;
while(st<=dr)
{
int m=(st+dr)/2;
if(a[m].first<a[i].first+1)
st=m+1;
else if(a[m].first>a[i].first+1)
dr=m-1;
else {
if(a[m].second>=a[i].second)
{
poz=m;
dr=m-1;
}
else st=m+1;
}
}
lift[i][0]=poz;
}
for(j=1;j<=20;j++)
for(i=1;i<=n;i++)
lift[i][j]=lift[lift[i][j-1]][j-1];
cin>>t;
while(t--)
{
cin>>sx>>sy>>fx>>fy;
if(sx>fx)
{
cout<<"No\n";
}
else if(sx==fx)
{
if(sy<=fy)
cout<<"Yes\n";
else cout<<"No\n";
}
else {
if(sy>fy)
{
cout<<"No\n";
continue;
}
int st=1;
int dr=n;
int poz=0;
while(st<=dr)
{
int m=(st+dr)/2;
if(a[m].first<sx)
st=m+1;
else if(a[m].first>sx)
dr=m-1;
else {
if(a[m].second<sy)
st=m+1;
else {
dr=m-1;
poz=m;
}
}
}
if(!poz)
{
cout<<"No\n";
continue;
}
int di=fx-sx-1;
for(j=0;j<=30;j++)
if(di&(1<<j))
poz=lift[poz][j];
if(poz&&a[poz].second<=fy)
cout<<"Yes\n";
else cout<<"No\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1484 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
5 ms |
1860 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
1284 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
29260 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
110 ms |
31108 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
103 ms |
30796 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
127 ms |
31116 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
241 ms |
31240 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
254 ms |
41576 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
260 ms |
41532 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
254 ms |
41640 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
256 ms |
41696 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
262 ms |
41524 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1132 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
1356 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
5 ms |
1372 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
1484 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
5 ms |
1360 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
1356 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
338 ms |
29976 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
329 ms |
41616 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
286 ms |
41856 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
386 ms |
41708 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
275 ms |
41676 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
268 ms |
41708 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
256 ms |
41756 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
265 ms |
41768 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
363 ms |
41600 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
350 ms |
41656 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
355 ms |
41680 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
230 ms |
41740 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
235 ms |
41700 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
294 ms |
41692 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
250 ms |
41684 KB |
200000 token(s): yes count is 129674, no count is 70326 |