Submission #895503

# Submission time Handle Problem Language Result Execution time Memory
895503 2023-12-30T06:34:43 Z jellybean Trampoline (info1cup20_trampoline) C++17
100 / 100
514 ms 63324 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int par[200005];
pair<int,int>arr[200005];
map<pair<int,int>,int>m;
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);
	int cnt=0;
	for(auto i: arr) m[i] = cnt, cnt++;
	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;
	}
	
	for(int i=0; i<n; i++) twok[i][0] = par[i];
	for(int k=1; 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(m[*it],x2-x1-1);
		if(P==-1 or arr[P].second > y2)cout<<"No\n";
		else cout<<"Yes\n";
	}	
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7260 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 7516 KB 200 token(s): yes count is 70, no count is 130
3 Correct 8 ms 5060 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 124 ms 50512 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 128 ms 52408 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 122 ms 51916 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 124 ms 52308 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 283 ms 58960 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 288 ms 62880 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 270 ms 63160 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 305 ms 62880 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 314 ms 62800 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 298 ms 62804 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4956 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 8 ms 5212 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 8 ms 5212 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 8 ms 5348 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 5212 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 8 ms 5400 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 455 ms 58704 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 422 ms 62744 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 326 ms 63064 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 467 ms 62732 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 384 ms 62780 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 365 ms 62800 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 366 ms 62804 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 317 ms 63060 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 445 ms 62856 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 514 ms 62724 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 500 ms 63108 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 294 ms 62800 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 301 ms 63008 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 368 ms 62800 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 304 ms 63324 KB 200000 token(s): yes count is 129674, no count is 70326