답안 #1041343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041343 2024-08-01T22:06:46 Z elotelo966 Trampoline (info1cup20_trampoline) C++17
0 / 100
472 ms 62036 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 200005
#define fi first
#define se second

vector<pair<int,int>> v[lim];

int x[lim],y[lim];

set<int> st;

map<int,int> mp;

int timer,l;

int up[lim][25];

int32_t main(){
	faster
	int r,c,n;cin>>r>>c>>n;
	l=ceil(log2(n));
	FOR{
		cin>>x[i]>>y[i];
		st.insert(x[i]);
	}
	
	for(auto a:st){
		mp[a]=++timer;
	}
	
	FOR{
		v[mp[x[i]]].push_back({y[i],i});
	}
	
	for(int i=1;i<=timer;i++){
		sort(v[i].begin(),v[i].end());
	}
	
	FOR{
		if(mp.find(x[i]+1)==mp.end())continue;
		if(v[mp[x[i]+1]].back().fi<y[i])continue;
		int tut=lower_bound(v[mp[x[i]+1]].begin(),v[mp[x[i]+1]].end(),make_pair(y[i],0ll))-v[mp[x[i]+1]].begin();
		up[i][0]=v[mp[x[i]+1]][tut].se;
	}
	
	for(int i=1;i<=l;i++){
		for(int j=1;j<=n;j++){
			up[j][i]=up[up[j][i-1]][i-1];
		}
	}
	
	int q;cin>>q;
	
	while(q--){
		int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
		if(y1>y2){
			cout<<"No"<<'\n';
			continue;
		}
		if(x1==x2){
			cout<<"Yes"<<'\n';
			continue;
		}
		if(v[mp[x1]].back().fi<y1){
			cout<<"No"<<'\n';
			continue;
		}
		int node=lower_bound(v[mp[x1]].begin(),v[mp[x1]].end(),make_pair(y1,0ll))-v[mp[x1]].begin();
		node=v[mp[x1]][node].se;
		for(int i=l;i>=0;i--){
			if(!up[node][i] && x[up[node][i]]<x2){
				node=up[node][i];
			}
		}
		
		if(y[node]<=y2)cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
		
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 12636 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 136 ms 53184 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 150 ms 52672 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 12632 KB expected NO, found YES [17th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 472 ms 62036 KB expected NO, found YES [12th token]
2 Halted 0 ms 0 KB -