Submission #1008847

# Submission time Handle Problem Language Result Execution time Memory
1008847 2024-06-27T01:33:05 Z emptypringlescan Trampoline (info1cup20_trampoline) C++17
100 / 100
243 ms 30408 KB
#include <bits/stdc++.h>
using namespace std;
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int r,c,n;
	cin >> r >> c >> n;
	vector<pair<int,int> > grr; 
	vector<pair<int,int> >::iterator it;
	for(int i=0; i<n; i++){
		int x,y;
		cin >> x >> y;
		grr.push_back({x,y});
	}
	sort(grr.begin(),grr.end());
	int par[20][n];
	memset(par,-1,sizeof(par));
	for(int i=0; i<n; i++){
		it=lower_bound(grr.begin(),grr.end(),make_pair(grr[i].first+1,grr[i].second));
		if(it!=grr.end()&&it->first==grr[i].first+1){
			par[0][i]=it-grr.begin();
		}
	}
	for(int i=1; i<20; i++){
		for(int j=0; j<n; j++){
			if(par[i-1][j]==-1) continue;
			par[i][j]=par[i-1][par[i-1][j]];
		}
	}
	int q;
	cin >> q;
	while(q--){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if(a>c){
			cout << "No\n";
			continue;
		}
		else if(a==c){
			if(b>d) cout << "No\n";
			else cout << "Yes\n";
			continue;
		}
		it=lower_bound(grr.begin(),grr.end(),make_pair(a,b));
		if(it==grr.end()||it->first!=a){
			cout << "No\n";
			continue;
		}
		int cur=it-grr.begin();
		for(int i=19; i>=0; i--){
			if(par[i][cur]==-1) continue;
			if(grr[par[i][cur]].first<c) cur=par[i][cur];
		}
		if(grr[cur].first==c-1&&grr[cur].second<=d) cout << "Yes\n";
		else cout << "No\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1372 KB 200 token(s): yes count is 21, no count is 179
2 Correct 3 ms 1372 KB 200 token(s): yes count is 70, no count is 130
3 Correct 2 ms 1116 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 64 ms 19632 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 55 ms 19656 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 58 ms 19148 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 60 ms 19524 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 171 ms 30148 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 193 ms 30148 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 184 ms 29896 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 224 ms 30148 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 212 ms 30148 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 216 ms 29976 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1116 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 4 ms 1116 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 4 ms 1116 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 4 ms 1116 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 4 ms 1116 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 3 ms 1096 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 216 ms 30092 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 209 ms 30152 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 165 ms 30148 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 225 ms 30068 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 194 ms 30148 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 163 ms 30052 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 185 ms 30128 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 187 ms 30192 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 223 ms 30148 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 243 ms 30152 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 242 ms 30144 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 205 ms 30156 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 189 ms 30152 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 234 ms 30408 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 183 ms 30216 KB 200000 token(s): yes count is 129674, no count is 70326