Submission #972224

# Submission time Handle Problem Language Result Execution time Memory
972224 2024-04-30T08:59:09 Z penguin133 Trampoline (info1cup20_trampoline) C++17
54 / 100
602 ms 58772 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int par[20][200005];
int r, c, n, X[200005], Y[200005];
map <int, vector <pi> > mp;

void solve(){
	cin >> r >> c >> n;
	for(int i = 1; i <= n; i++)cin >> X[i] >> Y[i], mp[X[i]].push_back({Y[i], i});
	for(auto &[i, j] : mp){
		sort(j.begin(), j.end());
	}
	for(int i = 1; i <= n; i++){
		pi brr = {Y[i], 0};
		auto tmp = lower_bound(mp[X[i] + 1].begin(), mp[X[i] + 1].end(), brr) - mp[X[i] + 1].begin();
		if(tmp == (int)mp[X[i] + 1].size())par[0][i] = -1;
		else par[0][i] = mp[X[i] + 1][tmp].se;
		//cout << par[0][i] << ' ';
	}
	for(int i = 1; i <= 19; i++){
		for(int j = 1; j <= n; j++){
			if(par[i - 1][j] == -1)par[i][j] = -1;
			else 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 << "Yes\n";
			continue;
		}
		if(c - a - 1 > n){
			cout << "No\n";
			continue;
		}
		pi brr = {b, 0};
		auto tmp = lower_bound(mp[a].begin(), mp[a].end(), brr) - mp[a].begin();
		if(tmp == (int)mp[a].size()){
			cout << "No\n";
			continue;
		}
		else tmp = mp[a][tmp].se;
		//jump c - a times
		int cur = tmp;
		for(int i = 19; i >= 0; i--){
			if((c - a - 1) >> i & 1)cur = par[i][cur];
			if(cur == -1)break;
		}
		if(cur == -1 || Y[cur] > d){
			cout << "No\n";
		}
		else cout << "Yes\n";
	}
}

main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int tc = 1;
	//cin >> tc;
	for(int tc1=1;tc1<=tc;tc1++){
		// cout << "Case #" << tc1 << ": ";
		solve();
	}
}

Compilation message

trampoline.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 23896 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 21980 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 19680 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 146 ms 42384 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 148 ms 42364 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 117 ms 40748 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 141 ms 42324 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 190 ms 51720 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 203 ms 51108 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 227 ms 51004 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 287 ms 52380 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 305 ms 52572 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 433 ms 57640 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 19800 KB expected NO, found YES [16th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 602 ms 58772 KB 200000 token(s): yes count is 171404, no count is 28596
2 Incorrect 457 ms 54352 KB expected NO, found YES [22020th token]
3 Halted 0 ms 0 KB -