Submission #726517

# Submission time Handle Problem Language Result Execution time Memory
726517 2023-04-19T03:22:11 Z hollwo_pelw Game (APIO22_game) C++17
100 / 100
1298 ms 57476 KB
#include "game.h"

#ifdef hollwo_pelw_local
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 5;

int n, k, tl[N], tr[N], res = 0;
vector<int> gi[N], go[N];

void init(int _n, int _k) {
	n = _n, k = _k;
	for (int i = 0; i < k; i++)
		tl[i] = tr[i] = i;
	for (int i = k; i < n; i++)
		tl[i] = tr[i] = i;
	for (int i = k; i < n; i++)
		tl[i] = -1, tr[i] = k;
}

inline int mid(int u) {
	return tl[u] + (tr[u] - tl[u]) / 2; // (tl[u] + tr[u]) / 2;
}

inline void debug(int u) {
	cout << "[" << tl[u] << ", " << mid(u) << "] -> " << u << " -> [" << mid(u) << ", " << tr[u] << "]" << endl;
}

inline int update(int u, int v) {
	if (tr[u] <= tl[v]) return 0;
	if (tl[u] >= tr[v]) return 1;

	// debug(u);
	// debug(v);

	while (mid(v) < tl[u]) {
		// cout << "UPDaTE " << v  << endl;
		// debug(v);
		tl[v] = mid(v) + 1;
		for (int x : go[v])
			if (update(v, x)) return 1;
	}

	while (mid(u) >= tr[v]) {
		// cout << "UpdAte " << u << endl;
		// debug(u);
		tr[u] = mid(u);
		for (int x : gi[u])
			if (update(x, u)) return 1;
	}

	return 0;
}

int add_teleporter(int u, int v) {
	if (v <= u && u < k)
		return 1;
	if (u == v) return 0;

	// cout << "ADD " << u << " -> " << v << endl;

	go[u].push_back(v);
	gi[v].push_back(u);

	return update(u, v);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 10 ms 14344 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 7 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 10 ms 14344 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 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 11 ms 14288 KB Output is correct
11 Correct 9 ms 14352 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14328 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14412 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 10 ms 14344 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 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 11 ms 14288 KB Output is correct
11 Correct 9 ms 14352 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14328 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14412 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 10 ms 14412 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 9 ms 14544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 10 ms 14344 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 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 11 ms 14288 KB Output is correct
11 Correct 9 ms 14352 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14328 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14412 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 10 ms 14412 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 9 ms 14544 KB Output is correct
30 Correct 25 ms 15748 KB Output is correct
31 Correct 11 ms 15032 KB Output is correct
32 Correct 29 ms 17864 KB Output is correct
33 Correct 24 ms 16436 KB Output is correct
34 Correct 46 ms 19400 KB Output is correct
35 Correct 44 ms 17480 KB Output is correct
36 Correct 49 ms 16456 KB Output is correct
37 Correct 43 ms 16356 KB Output is correct
38 Correct 43 ms 16176 KB Output is correct
39 Correct 53 ms 16300 KB Output is correct
40 Correct 54 ms 19192 KB Output is correct
41 Correct 49 ms 17096 KB Output is correct
42 Correct 40 ms 16712 KB Output is correct
43 Correct 46 ms 17456 KB Output is correct
44 Correct 49 ms 17128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 10 ms 14344 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 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 11 ms 14288 KB Output is correct
11 Correct 9 ms 14352 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 10 ms 14328 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14412 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 10 ms 14412 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 9 ms 14544 KB Output is correct
30 Correct 25 ms 15748 KB Output is correct
31 Correct 11 ms 15032 KB Output is correct
32 Correct 29 ms 17864 KB Output is correct
33 Correct 24 ms 16436 KB Output is correct
34 Correct 46 ms 19400 KB Output is correct
35 Correct 44 ms 17480 KB Output is correct
36 Correct 49 ms 16456 KB Output is correct
37 Correct 43 ms 16356 KB Output is correct
38 Correct 43 ms 16176 KB Output is correct
39 Correct 53 ms 16300 KB Output is correct
40 Correct 54 ms 19192 KB Output is correct
41 Correct 49 ms 17096 KB Output is correct
42 Correct 40 ms 16712 KB Output is correct
43 Correct 46 ms 17456 KB Output is correct
44 Correct 49 ms 17128 KB Output is correct
45 Correct 258 ms 28032 KB Output is correct
46 Correct 16 ms 17104 KB Output is correct
47 Correct 14 ms 17104 KB Output is correct
48 Correct 341 ms 40744 KB Output is correct
49 Correct 303 ms 35436 KB Output is correct
50 Correct 681 ms 46660 KB Output is correct
51 Correct 834 ms 42552 KB Output is correct
52 Correct 585 ms 35360 KB Output is correct
53 Correct 833 ms 35588 KB Output is correct
54 Correct 861 ms 35336 KB Output is correct
55 Correct 994 ms 35616 KB Output is correct
56 Correct 1132 ms 35400 KB Output is correct
57 Correct 483 ms 29416 KB Output is correct
58 Correct 517 ms 29560 KB Output is correct
59 Correct 485 ms 29616 KB Output is correct
60 Correct 509 ms 29596 KB Output is correct
61 Correct 608 ms 29392 KB Output is correct
62 Correct 449 ms 37656 KB Output is correct
63 Correct 331 ms 34308 KB Output is correct
64 Correct 1046 ms 57476 KB Output is correct
65 Correct 494 ms 35424 KB Output is correct
66 Correct 417 ms 31228 KB Output is correct
67 Correct 789 ms 40228 KB Output is correct
68 Correct 229 ms 26260 KB Output is correct
69 Correct 59 ms 20128 KB Output is correct
70 Correct 757 ms 39076 KB Output is correct
71 Correct 308 ms 28964 KB Output is correct
72 Correct 242 ms 24852 KB Output is correct
73 Correct 710 ms 37156 KB Output is correct
74 Correct 1298 ms 35380 KB Output is correct
75 Correct 1102 ms 42128 KB Output is correct
76 Correct 1127 ms 47524 KB Output is correct