답안 #972230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972230 2024-04-30T09:03:46 Z penguin133 Trampoline (info1cup20_trampoline) C++17
100 / 100
771 ms 69384 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 << (b <= d ? "Yes\n" : "No\n");
			continue;
		}
		if(c - a - 1 > n || c < a){
			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(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 23900 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 20056 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 17884 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 42316 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 135 ms 42324 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 117 ms 40732 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 148 ms 42608 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 188 ms 49088 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 197 ms 48680 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 225 ms 48568 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 294 ms 49764 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 293 ms 49804 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 414 ms 55544 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 23644 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 19756 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 18520 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 7 ms 17756 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 9 ms 17900 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 17876 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 596 ms 56548 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 480 ms 52000 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 220 ms 51268 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 771 ms 69384 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 376 ms 57092 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 221 ms 51656 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 227 ms 51588 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 242 ms 50980 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 589 ms 57584 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 547 ms 58444 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 633 ms 63060 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 186 ms 50608 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 201 ms 51548 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 310 ms 52448 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 207 ms 50828 KB 200000 token(s): yes count is 129674, no count is 70326