Submission #578325

# Submission time Handle Problem Language Result Execution time Memory
578325 2022-06-16T11:26:01 Z handlename Game (APIO22_game) C++17
100 / 100
1284 ms 69636 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
int n,k;
vector<int> adj[300001],rev[300001];
pair<int,int> range[300001];
//rightmost special node to go i, leftmost special node i can go to
void init(int N,int K){
	n=N;
	k=K;
	for (int i=1;i<=k;i++){
		//adj[i].pb(i+1);
		//rev[i+1].pb(i);
		range[i]=mp(i,i);
	}
	for (int i=k+1;i<=n;i++){
		range[i]=mp(0,k+1);
	}
}
bool upd(int u,int v){
	if (range[u].second<=range[v].first) return false;
	if (range[u].first>=range[v].second) return true;
	while ((range[v].first+range[v].second)/2<range[u].first){
		range[v].first=(range[v].first+range[v].second)/2+1;
		for (auto i:adj[v]){
			if (upd(v,i)) return true;
		}
	}
	while ((range[u].second+range[u].first)/2>=range[v].second){
		range[u].second=(range[u].second+range[u].first)/2;
		for (auto i:rev[u]){
			if (upd(i,u)) return true;
		}
	}
	return false;	
}
int add_teleporter(int u,int v){
	u++;
	v++;
	if (u>=v && u<=k) return 1;
	if (u==v) return 0;
	adj[u].pb(v);
	rev[v].pb(u);
	return upd(u,v);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14400 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 7 ms 14364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14400 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 7 ms 14364 KB Output is correct
20 Correct 9 ms 14416 KB Output is correct
21 Correct 7 ms 14300 KB Output is correct
22 Correct 9 ms 14404 KB Output is correct
23 Correct 8 ms 14408 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 12 ms 14404 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 10 ms 14536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14400 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 7 ms 14364 KB Output is correct
20 Correct 9 ms 14416 KB Output is correct
21 Correct 7 ms 14300 KB Output is correct
22 Correct 9 ms 14404 KB Output is correct
23 Correct 8 ms 14408 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 12 ms 14404 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 10 ms 14536 KB Output is correct
30 Correct 22 ms 15660 KB Output is correct
31 Correct 12 ms 14928 KB Output is correct
32 Correct 36 ms 18808 KB Output is correct
33 Correct 26 ms 16444 KB Output is correct
34 Correct 44 ms 20992 KB Output is correct
35 Correct 41 ms 18056 KB Output is correct
36 Correct 39 ms 16456 KB Output is correct
37 Correct 39 ms 16436 KB Output is correct
38 Correct 41 ms 16196 KB Output is correct
39 Correct 39 ms 16200 KB Output is correct
40 Correct 55 ms 20680 KB Output is correct
41 Correct 40 ms 17384 KB Output is correct
42 Correct 36 ms 16972 KB Output is correct
43 Correct 39 ms 17700 KB Output is correct
44 Correct 48 ms 17624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14400 KB Output is correct
15 Correct 8 ms 14396 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 7 ms 14364 KB Output is correct
20 Correct 9 ms 14416 KB Output is correct
21 Correct 7 ms 14300 KB Output is correct
22 Correct 9 ms 14404 KB Output is correct
23 Correct 8 ms 14408 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 12 ms 14404 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 10 ms 14536 KB Output is correct
30 Correct 22 ms 15660 KB Output is correct
31 Correct 12 ms 14928 KB Output is correct
32 Correct 36 ms 18808 KB Output is correct
33 Correct 26 ms 16444 KB Output is correct
34 Correct 44 ms 20992 KB Output is correct
35 Correct 41 ms 18056 KB Output is correct
36 Correct 39 ms 16456 KB Output is correct
37 Correct 39 ms 16436 KB Output is correct
38 Correct 41 ms 16196 KB Output is correct
39 Correct 39 ms 16200 KB Output is correct
40 Correct 55 ms 20680 KB Output is correct
41 Correct 40 ms 17384 KB Output is correct
42 Correct 36 ms 16972 KB Output is correct
43 Correct 39 ms 17700 KB Output is correct
44 Correct 48 ms 17624 KB Output is correct
45 Correct 262 ms 28108 KB Output is correct
46 Correct 15 ms 17104 KB Output is correct
47 Correct 13 ms 17104 KB Output is correct
48 Correct 366 ms 45528 KB Output is correct
49 Correct 275 ms 35432 KB Output is correct
50 Correct 623 ms 54796 KB Output is correct
51 Correct 804 ms 46620 KB Output is correct
52 Correct 578 ms 35704 KB Output is correct
53 Correct 764 ms 35848 KB Output is correct
54 Correct 792 ms 35496 KB Output is correct
55 Correct 921 ms 35728 KB Output is correct
56 Correct 1069 ms 35512 KB Output is correct
57 Correct 482 ms 29616 KB Output is correct
58 Correct 430 ms 29516 KB Output is correct
59 Correct 483 ms 29708 KB Output is correct
60 Correct 524 ms 29356 KB Output is correct
61 Correct 560 ms 29344 KB Output is correct
62 Correct 426 ms 41920 KB Output is correct
63 Correct 372 ms 38496 KB Output is correct
64 Correct 1103 ms 69636 KB Output is correct
65 Correct 459 ms 37352 KB Output is correct
66 Correct 371 ms 33264 KB Output is correct
67 Correct 793 ms 42816 KB Output is correct
68 Correct 215 ms 26272 KB Output is correct
69 Correct 54 ms 20196 KB Output is correct
70 Correct 727 ms 42592 KB Output is correct
71 Correct 294 ms 29060 KB Output is correct
72 Correct 249 ms 24840 KB Output is correct
73 Correct 597 ms 39464 KB Output is correct
74 Correct 1284 ms 35448 KB Output is correct
75 Correct 1068 ms 47372 KB Output is correct
76 Correct 1077 ms 54200 KB Output is correct