Submission #349388

# Submission time Handle Problem Language Result Execution time Memory
349388 2021-01-17T14:02:23 Z Sho10 Trampoline (info1cup20_trampoline) C++17
0 / 100
289 ms 62828 KB
#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);
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 Incorrect 4 ms 2668 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 52460 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 275 ms 62828 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1900 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 289 ms 62660 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -