답안 #894792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894792 2023-12-29T03:20:50 Z jellybean Trampoline (info1cup20_trampoline) C++17
0 / 100
140 ms 99412 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int par[200005];
pair<int,int>arr[200005];
vector<int>adj[200005];
int twok[200005][21];

int findp(int x, int k){
	for(int i=0; i<21; i++){
		if(k&(1<<i)) x=twok[x][i];
		if(x==-1) return -1;
	}
	return x;
}
 
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int r,c,n; cin>>r>>c>>n;
	for(int i=0; i<n; i++){
		int a,b; cin>>a>>b;
		arr[i] = {a,b};
	}
	sort(arr,arr+n);
	for(int i=0; i<n; i++){
		pair<int,int>p = arr[i];
		p.first++;
		auto it = lower_bound(arr,arr+n,p);
		if(it==arr+n) par[i] = -1;
		else if(it->first > p.first) par[i] = -1;
		else{
			par[i] = it-arr;
			adj[par[i]].push_back(i);
		}
	}
	
	for(int i=0; i<n; i++) twok[i][0] = par[i];
	for(int k=0; k<21; k++){
		for(int x=0; x<n; x++){
			int half = twok[x][k-1];
			if(half==-1) twok[x][k] = -1;
			else twok[x][k] = twok[half][k-1];
		}
	}
	
	int t; cin>>t;
	while(t--){
		int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
		
		if(x2<x1 or y2<y1){cout<<"No\n"; continue;}
		if(x1==x2){cout<<"Yes\n"; continue;}
		
		pair<int,int>p = {x1,y1};
		auto it = lower_bound(arr,arr+n,p);
		if(it==arr+n){cout<<"No\n"; continue;}
		if(it->first > x1){cout<<"No\n"; continue;}
		
		int P = findp(x1,x2-x1);
		if(P==-1 or arr[P].second > y2)cout<<"No\n";
		else cout<<"Yes\n";
	}	
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 13148 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 48272 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 125 ms 95168 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 26228 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 140 ms 99412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -