Submission #578314

# Submission time Handle Problem Language Result Execution time Memory
578314 2022-06-16T11:07:09 Z handlename Game (APIO22_game) C++17
100 / 100
1277 ms 69764 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;
	if (range[u]==range[v]) return false;
	//u1 u u2
	//v1 v v2
	//u2>v1 and u1<v2
	//if we use u->v edge,v1=max(u1,v1) and u2=min(u2,v2)
	if ((range[v].first+range[v].second)/2<range[u].first){
		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;
		}
	}
	if ((range[u].second+range[u].first)/2>=range[v].second){
		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 7 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 8 ms 14288 KB Output is correct
7 Correct 9 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 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 8 ms 14288 KB Output is correct
7 Correct 9 ms 14288 KB Output is correct
8 Correct 8 ms 14376 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14368 KB Output is correct
11 Correct 8 ms 14284 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 7 ms 14288 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 10 ms 14304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 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 8 ms 14288 KB Output is correct
7 Correct 9 ms 14288 KB Output is correct
8 Correct 8 ms 14376 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14368 KB Output is correct
11 Correct 8 ms 14284 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 7 ms 14288 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 10 ms 14304 KB Output is correct
20 Correct 10 ms 14416 KB Output is correct
21 Correct 8 ms 14408 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 10 ms 14420 KB Output is correct
26 Correct 11 ms 14388 KB Output is correct
27 Correct 12 ms 14416 KB Output is correct
28 Correct 9 ms 14544 KB Output is correct
29 Correct 10 ms 14544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 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 8 ms 14288 KB Output is correct
7 Correct 9 ms 14288 KB Output is correct
8 Correct 8 ms 14376 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14368 KB Output is correct
11 Correct 8 ms 14284 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 7 ms 14288 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 10 ms 14304 KB Output is correct
20 Correct 10 ms 14416 KB Output is correct
21 Correct 8 ms 14408 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 10 ms 14420 KB Output is correct
26 Correct 11 ms 14388 KB Output is correct
27 Correct 12 ms 14416 KB Output is correct
28 Correct 9 ms 14544 KB Output is correct
29 Correct 10 ms 14544 KB Output is correct
30 Correct 24 ms 15720 KB Output is correct
31 Correct 16 ms 14928 KB Output is correct
32 Correct 27 ms 17512 KB Output is correct
33 Correct 31 ms 16456 KB Output is correct
34 Correct 41 ms 20928 KB Output is correct
35 Correct 37 ms 17960 KB Output is correct
36 Correct 44 ms 16468 KB Output is correct
37 Correct 36 ms 16384 KB Output is correct
38 Correct 30 ms 16176 KB Output is correct
39 Correct 42 ms 16280 KB Output is correct
40 Correct 75 ms 20648 KB Output is correct
41 Correct 38 ms 17408 KB Output is correct
42 Correct 38 ms 16972 KB Output is correct
43 Correct 46 ms 17772 KB Output is correct
44 Correct 52 ms 17508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 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 8 ms 14288 KB Output is correct
7 Correct 9 ms 14288 KB Output is correct
8 Correct 8 ms 14376 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14368 KB Output is correct
11 Correct 8 ms 14284 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14296 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 7 ms 14288 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 10 ms 14304 KB Output is correct
20 Correct 10 ms 14416 KB Output is correct
21 Correct 8 ms 14408 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 10 ms 14420 KB Output is correct
26 Correct 11 ms 14388 KB Output is correct
27 Correct 12 ms 14416 KB Output is correct
28 Correct 9 ms 14544 KB Output is correct
29 Correct 10 ms 14544 KB Output is correct
30 Correct 24 ms 15720 KB Output is correct
31 Correct 16 ms 14928 KB Output is correct
32 Correct 27 ms 17512 KB Output is correct
33 Correct 31 ms 16456 KB Output is correct
34 Correct 41 ms 20928 KB Output is correct
35 Correct 37 ms 17960 KB Output is correct
36 Correct 44 ms 16468 KB Output is correct
37 Correct 36 ms 16384 KB Output is correct
38 Correct 30 ms 16176 KB Output is correct
39 Correct 42 ms 16280 KB Output is correct
40 Correct 75 ms 20648 KB Output is correct
41 Correct 38 ms 17408 KB Output is correct
42 Correct 38 ms 16972 KB Output is correct
43 Correct 46 ms 17772 KB Output is correct
44 Correct 52 ms 17508 KB Output is correct
45 Correct 282 ms 28056 KB Output is correct
46 Correct 14 ms 17104 KB Output is correct
47 Correct 13 ms 17092 KB Output is correct
48 Correct 360 ms 45560 KB Output is correct
49 Correct 281 ms 35472 KB Output is correct
50 Correct 632 ms 54916 KB Output is correct
51 Correct 806 ms 46816 KB Output is correct
52 Correct 573 ms 35532 KB Output is correct
53 Correct 740 ms 35680 KB Output is correct
54 Correct 770 ms 35356 KB Output is correct
55 Correct 991 ms 35712 KB Output is correct
56 Correct 1154 ms 35512 KB Output is correct
57 Correct 445 ms 29380 KB Output is correct
58 Correct 503 ms 29384 KB Output is correct
59 Correct 509 ms 29656 KB Output is correct
60 Correct 481 ms 29564 KB Output is correct
61 Correct 590 ms 29812 KB Output is correct
62 Correct 518 ms 41796 KB Output is correct
63 Correct 365 ms 38580 KB Output is correct
64 Correct 1078 ms 69764 KB Output is correct
65 Correct 501 ms 37336 KB Output is correct
66 Correct 390 ms 33264 KB Output is correct
67 Correct 819 ms 42888 KB Output is correct
68 Correct 234 ms 26328 KB Output is correct
69 Correct 74 ms 20168 KB Output is correct
70 Correct 765 ms 42528 KB Output is correct
71 Correct 366 ms 29072 KB Output is correct
72 Correct 252 ms 24888 KB Output is correct
73 Correct 675 ms 39400 KB Output is correct
74 Correct 1277 ms 35396 KB Output is correct
75 Correct 1051 ms 47296 KB Output is correct
76 Correct 1075 ms 54224 KB Output is correct