#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,k,q,dp[2000005][30];
pair<ll,ll>a[200005];
ll calc(ll x,ll y){
ll l=1,r=k,ans=k+1;
while(l<=r){
ll mid=(l+r)/2;
if(a[mid]>=mp(x,y)){
ans=mid;
r=mid-1;
}else l=mid+1;
}
if(ans==k+1){
return 0;
}
if(a[ans].f>x){
return 0;
}
return ans;
}
int32_t main(){
CODE_START;
cin>>n>>m>>k;
for(ll i=1;i<=k;i++)
{
cin>>a[i].f>>a[i].s;
}
a[0]=mp(LINF,LINF);
sort(a+1,a+k+1);
for(ll i=1;i<=k;i++)
{
dp[i][0]=calc(a[i].f+1,a[i].s);
}
for(ll j=1;j<30;j++)
{
for(ll i=1;i<=k;i++)
{
dp[i][j]=dp[dp[i][j-1]][j-1];
}
}
cin>>q;
while(q--){
ll x1,x2,y1,y2;
cin>>x1>>y1>>x2>>y2;
if(x2<x1){
cout<<"No"<<endl;
continue;
}
if(y2<y1){
cout<<"No"<<endl;
continue;
}
if(x1==x2){
cout<<"Yes"<<endl;
continue;
}
ll pos=calc(x1,y1),l=x2-x1-1;
for(ll j=0;j<30;j++)
{
if(l&(1<<j)){
pos=dp[pos][j];
}
}
if(a[pos].s<=y2){
cout<<"Yes"<<endl;
}else cout<<"No"<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2540 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
6 ms |
2924 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
4 ms |
2176 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
50492 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
172 ms |
52352 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
168 ms |
51948 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
174 ms |
52332 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
319 ms |
51180 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
332 ms |
62956 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
335 ms |
62828 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
345 ms |
62956 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
354 ms |
62828 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
341 ms |
62700 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1644 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
7 ms |
1900 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
7 ms |
1900 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
7 ms |
1900 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
7 ms |
1900 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
7 ms |
1900 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
490 ms |
51308 KB |
200000 token(s): yes count is 171404, no count is 28596 |
2 |
Correct |
500 ms |
62968 KB |
200000 token(s): yes count is 161254, no count is 38746 |
3 |
Correct |
370 ms |
62916 KB |
200000 token(s): yes count is 117455, no count is 82545 |
4 |
Correct |
541 ms |
62884 KB |
200000 token(s): yes count is 182118, no count is 17882 |
5 |
Correct |
410 ms |
62828 KB |
200000 token(s): yes count is 167565, no count is 32435 |
6 |
Correct |
379 ms |
62956 KB |
200000 token(s): yes count is 156797, no count is 43203 |
7 |
Correct |
381 ms |
62956 KB |
200000 token(s): yes count is 156797, no count is 43203 |
8 |
Correct |
360 ms |
62956 KB |
200000 token(s): yes count is 122100, no count is 77900 |
9 |
Correct |
485 ms |
62828 KB |
200000 token(s): yes count is 139670, no count is 60330 |
10 |
Correct |
498 ms |
63212 KB |
200000 token(s): yes count is 165806, no count is 34194 |
11 |
Correct |
515 ms |
63084 KB |
200000 token(s): yes count is 175646, no count is 24354 |
12 |
Correct |
322 ms |
62956 KB |
200000 token(s): yes count is 134695, no count is 65305 |
13 |
Correct |
329 ms |
63108 KB |
200000 token(s): yes count is 126733, no count is 73267 |
14 |
Correct |
417 ms |
63044 KB |
200000 token(s): yes count is 155290, no count is 44710 |
15 |
Correct |
336 ms |
62956 KB |
200000 token(s): yes count is 129674, no count is 70326 |