Submission #775622

# Submission time Handle Problem Language Result Execution time Memory
775622 2023-07-06T16:16:02 Z pulsatio Trampoline (info1cup20_trampoline) C++14
100 / 100
926 ms 72108 KB
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
using namespace std;

const int MAX = 2e5 + 10;
int r,c,n,t,x[MAX],y[MAX], sp[MAX][30];

map<int,vector<int>> m;
map< pair<int,int> , int  > ind; 

int up(int a,int b){
	auto it = lower_bound(all(m[a]),b);
	if(it == m[a].end()) return 0;
	return ind[{a,*it}];
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> r >> c >> n;

	
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> y[i];
		m[x[i]].push_back(y[i]);
		ind[{x[i],y[i]}] = i;
	}


	for(auto &it: m) sort(all(it.second));

	for(int i = 1; i <= n; i++)
		sp[i][0] = up(x[i]+1,y[i]);

	for(int j = 1; j < 30; j++)
		for(int i = 1; i <= n; i++) sp[i][j] = sp[sp[i][j-1]][j-1];	
	cin >> t;
	int x1,y1,x2,y2;
	while(t--){
		cin >> x1 >> y1 >> x2 >> y2;
		
		int d = x2-x1;
		if(x1 > x2 || y1 > y2) cout << "No\n";
		else if(d == 0) cout << "Yes\n";
		else{
			int u = up(x1,y1);
		//	cout << d << endl;
			d--;
			for(int i = 0; i < 30; i++)
				if(d&(1<<i)) u = sp[u][i];
		//	cout << u << endl;
			if(u != 0 && y[u] <= y2)
				cout << "Yes\n";
			else
				cout << "No\n"; 
		}


	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2004 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 2184 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 1620 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 321 ms 39556 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 333 ms 39500 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 292 ms 39088 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 305 ms 39500 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 403 ms 39288 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 404 ms 39520 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 448 ms 39588 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 486 ms 40028 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 496 ms 40036 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 648 ms 46156 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1340 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 6 ms 1236 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 2220 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 1236 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 1364 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1316 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 909 ms 47520 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 722 ms 53984 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 465 ms 51288 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 926 ms 72108 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 616 ms 58692 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 508 ms 51336 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 494 ms 51392 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 455 ms 51096 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 759 ms 57736 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 785 ms 57632 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 913 ms 64920 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 367 ms 51076 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 421 ms 51140 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 547 ms 51648 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 471 ms 51144 KB 200000 token(s): yes count is 129674, no count is 70326