Submission #725214

# Submission time Handle Problem Language Result Execution time Memory
725214 2023-04-17T03:32:15 Z SanguineChameleon Game (APIO22_game) C++17
60 / 100
4000 ms 21212 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

const int maxN = 3e5 + 20;
int max_in[maxN];
vector<int> adj[maxN];
int n, k;

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

void dfs(int u) {
	for (auto v: adj[u]) {
		if (max_in[u] > max_in[v]) {
			max_in[v] = max_in[u];
			dfs(v);
		}
	}
}

int add_teleporter(int u, int v) {
	int cur = max(max_in[u], (u < k ? u : -1));
	if (cur > max_in[v]) {
		max_in[v] = cur;
		dfs(v);
	}
	adj[u].push_back(v);
	for (int i = 0; i < k; i++) {
		if (max_in[i] >= i) {
			return 1;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 4 ms 7348 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 5 ms 7248 KB Output is correct
7 Correct 4 ms 7248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 4 ms 7348 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 5 ms 7248 KB Output is correct
7 Correct 4 ms 7248 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 4 ms 7248 KB Output is correct
14 Correct 4 ms 7248 KB Output is correct
15 Correct 4 ms 7248 KB Output is correct
16 Correct 4 ms 7248 KB Output is correct
17 Correct 4 ms 7248 KB Output is correct
18 Correct 5 ms 7248 KB Output is correct
19 Correct 4 ms 7248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 4 ms 7348 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 5 ms 7248 KB Output is correct
7 Correct 4 ms 7248 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 4 ms 7248 KB Output is correct
14 Correct 4 ms 7248 KB Output is correct
15 Correct 4 ms 7248 KB Output is correct
16 Correct 4 ms 7248 KB Output is correct
17 Correct 4 ms 7248 KB Output is correct
18 Correct 5 ms 7248 KB Output is correct
19 Correct 4 ms 7248 KB Output is correct
20 Correct 5 ms 7248 KB Output is correct
21 Correct 4 ms 7248 KB Output is correct
22 Correct 5 ms 7376 KB Output is correct
23 Correct 4 ms 7356 KB Output is correct
24 Correct 6 ms 7376 KB Output is correct
25 Correct 7 ms 7360 KB Output is correct
26 Correct 6 ms 7360 KB Output is correct
27 Correct 7 ms 7376 KB Output is correct
28 Correct 5 ms 7376 KB Output is correct
29 Correct 6 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 4 ms 7348 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 5 ms 7248 KB Output is correct
7 Correct 4 ms 7248 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 4 ms 7248 KB Output is correct
14 Correct 4 ms 7248 KB Output is correct
15 Correct 4 ms 7248 KB Output is correct
16 Correct 4 ms 7248 KB Output is correct
17 Correct 4 ms 7248 KB Output is correct
18 Correct 5 ms 7248 KB Output is correct
19 Correct 4 ms 7248 KB Output is correct
20 Correct 5 ms 7248 KB Output is correct
21 Correct 4 ms 7248 KB Output is correct
22 Correct 5 ms 7376 KB Output is correct
23 Correct 4 ms 7356 KB Output is correct
24 Correct 6 ms 7376 KB Output is correct
25 Correct 7 ms 7360 KB Output is correct
26 Correct 6 ms 7360 KB Output is correct
27 Correct 7 ms 7376 KB Output is correct
28 Correct 5 ms 7376 KB Output is correct
29 Correct 6 ms 7372 KB Output is correct
30 Correct 27 ms 7968 KB Output is correct
31 Correct 11 ms 7632 KB Output is correct
32 Correct 20 ms 8396 KB Output is correct
33 Correct 18 ms 8368 KB Output is correct
34 Correct 495 ms 9244 KB Output is correct
35 Correct 203 ms 8668 KB Output is correct
36 Correct 34 ms 8340 KB Output is correct
37 Correct 46 ms 8296 KB Output is correct
38 Correct 62 ms 8008 KB Output is correct
39 Correct 46 ms 8260 KB Output is correct
40 Correct 412 ms 9156 KB Output is correct
41 Correct 115 ms 8420 KB Output is correct
42 Correct 88 ms 8312 KB Output is correct
43 Correct 51 ms 9112 KB Output is correct
44 Correct 327 ms 9124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 4 ms 7348 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 5 ms 7248 KB Output is correct
7 Correct 4 ms 7248 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 4 ms 7248 KB Output is correct
14 Correct 4 ms 7248 KB Output is correct
15 Correct 4 ms 7248 KB Output is correct
16 Correct 4 ms 7248 KB Output is correct
17 Correct 4 ms 7248 KB Output is correct
18 Correct 5 ms 7248 KB Output is correct
19 Correct 4 ms 7248 KB Output is correct
20 Correct 5 ms 7248 KB Output is correct
21 Correct 4 ms 7248 KB Output is correct
22 Correct 5 ms 7376 KB Output is correct
23 Correct 4 ms 7356 KB Output is correct
24 Correct 6 ms 7376 KB Output is correct
25 Correct 7 ms 7360 KB Output is correct
26 Correct 6 ms 7360 KB Output is correct
27 Correct 7 ms 7376 KB Output is correct
28 Correct 5 ms 7376 KB Output is correct
29 Correct 6 ms 7372 KB Output is correct
30 Correct 27 ms 7968 KB Output is correct
31 Correct 11 ms 7632 KB Output is correct
32 Correct 20 ms 8396 KB Output is correct
33 Correct 18 ms 8368 KB Output is correct
34 Correct 495 ms 9244 KB Output is correct
35 Correct 203 ms 8668 KB Output is correct
36 Correct 34 ms 8340 KB Output is correct
37 Correct 46 ms 8296 KB Output is correct
38 Correct 62 ms 8008 KB Output is correct
39 Correct 46 ms 8260 KB Output is correct
40 Correct 412 ms 9156 KB Output is correct
41 Correct 115 ms 8420 KB Output is correct
42 Correct 88 ms 8312 KB Output is correct
43 Correct 51 ms 9112 KB Output is correct
44 Correct 327 ms 9124 KB Output is correct
45 Correct 161 ms 14176 KB Output is correct
46 Correct 12 ms 8648 KB Output is correct
47 Correct 12 ms 8656 KB Output is correct
48 Correct 281 ms 21212 KB Output is correct
49 Correct 215 ms 17932 KB Output is correct
50 Execution timed out 4042 ms 10756 KB Time limit exceeded
51 Halted 0 ms 0 KB -