Submission #426888

# Submission time Handle Problem Language Result Execution time Memory
426888 2021-06-14T10:44:28 Z oolimry Trampoline (info1cup20_trampoline) C++17
100 / 100
1008 ms 42080 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;

ii arr[200005];
map<int, vector<ii> > M;

int p[20][200005];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int R, C, n; cin >> R >> C >> n;
	
	for(int i = 1;i <= n;i++){
		cin >> arr[i].first >> arr[i].second;
		M[arr[i].first].push_back(ii(arr[i].second,i));
	}
	
	for(auto &p : M){
		sort(all(p.second));
	}
	
	for(auto &P : M){
		vector<ii> &A = P.second;
		if(M.find(P.first+1) == M.end()) continue;
		vector<ii> &B = M[P.first+1];
		
		for(ii a : A){
			auto it = lower_bound(all(B), ii(a.first, -1));
			if(it == B.end()) continue;
			
			p[0][a.second] = it->second;
		}
	}
	
	for(int k = 1;k <= 19;k++){
		for(int i = 1;i <= n;i++){
			p[k][i] = p[k-1][p[k-1][i]];
		}
	}
	
	int Q; cin >> Q;
	while(Q--){
		int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
		
		if(r1 > r2){
			cout << "No\n";
			continue;
		}
		if(r1 == r2){
			if(c1 <= c2) cout << "Yes\n";
			else cout << "No\n";
			
			continue;
		}
		
		if(M.find(r1) == M.end()){
			cout << "No\n";
			continue;
		}
		auto it = lower_bound(all(M[r1]), ii(c1, -1));
		if(it == M[r1].end()){
			cout << "No\n";
			continue;
		}
		
		int u = it->second;
		for(int k = 0;k <= 19;k++){
			if((r2-r1-1)&(1<<k)){
				u = p[k][u];
			}
		}
		
		
		if(u == 0){
			cout << "No\n";
			continue;
		}
		
		if(arr[u].second <= c2) cout << "Yes\n";
		else cout << "No\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1484 KB 200 token(s): yes count is 21, no count is 179
2 Correct 5 ms 1648 KB 200 token(s): yes count is 70, no count is 130
3 Correct 4 ms 1356 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 110 ms 24868 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 112 ms 25232 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 101 ms 23904 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 117 ms 25160 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 317 ms 24256 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 318 ms 23588 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 377 ms 23684 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 377 ms 24900 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 329 ms 24896 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 689 ms 30416 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 8 ms 972 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 1356 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 1736 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 7 ms 1356 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 11 ms 1420 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1228 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 876 ms 31596 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 677 ms 27440 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 323 ms 24140 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1008 ms 42080 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 563 ms 30128 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 406 ms 24628 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 326 ms 24516 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 293 ms 23832 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 738 ms 30720 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 729 ms 31172 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 912 ms 36188 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 323 ms 23452 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 290 ms 24288 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 448 ms 25256 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 310 ms 23760 KB 200000 token(s): yes count is 129674, no count is 70326