Submission #725359

# Submission time Handle Problem Language Result Execution time Memory
725359 2023-04-17T10:40:32 Z SanguineChameleon Game (APIO22_game) C++17
60 / 100
1098 ms 17628 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
 
const int maxN = 3e5 + 20;
int block;
int max_in[maxN];
int min_out[maxN];
vector<int> adj1[maxN];
vector<int> adj2[maxN];
bool done = false;
int n, k;
 
void init(int _n, int _k) {
	n = _n;
	k = _k;
	if (n > 30000) {
		block = sqrt(k);
	}
	else {
		block = 1;
	}
	for (int i = 0; i < k; i++) {
		max_in[i] = (i - 1) / block;
		min_out[i] = i / block;
	}
	for (int i = k; i < n; i++) {
		max_in[i] = -1 / block;
		min_out[i] = k / block;
	}
}
 
void update_in(int u, int val) {
	if (done) {
		return;
	}
	if (val <= max_in[u]) {
		return;
	}
	max_in[u] = val;
	if (max_in[u] >= min_out[u]) {
		done = true;
		return;
	}
	for (auto v: adj1[u]) {
		update_in(v, val);
	}
}
 
void update_out(int u, int val) {
	if (done) {
		return;
	}
	if (val >= min_out[u]) {
		return;
	}
	min_out[u] = val;
	if (max_in[u] >= min_out[u]) {
		done = true;
		return;
	}
	for (auto v: adj2[u]) {
		update_out(v, val);
	}
}
 
int add_teleporter(int u, int v) {
	update_in(v, max(max_in[u], (u < k ? u : -1) / block));
	update_out(u, min_out[v]);
	adj1[u].push_back(v);
	adj2[v].push_back(u);
	return done;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14288 KB Output is correct
7 Correct 7 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 14420 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 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 7 ms 14288 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 8 ms 14368 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14328 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 10 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 14420 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 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 7 ms 14288 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 8 ms 14368 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14328 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 10 ms 14288 KB Output is correct
20 Correct 7 ms 14416 KB Output is correct
21 Correct 7 ms 14412 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 12 ms 14364 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 9 ms 14476 KB Output is correct
28 Correct 10 ms 14420 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 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 7 ms 14288 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 8 ms 14368 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14328 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 10 ms 14288 KB Output is correct
20 Correct 7 ms 14416 KB Output is correct
21 Correct 7 ms 14412 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 12 ms 14364 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 9 ms 14476 KB Output is correct
28 Correct 10 ms 14420 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 24 ms 15660 KB Output is correct
31 Correct 11 ms 14928 KB Output is correct
32 Correct 28 ms 16580 KB Output is correct
33 Correct 31 ms 16420 KB Output is correct
34 Correct 1098 ms 17464 KB Output is correct
35 Correct 406 ms 16972 KB Output is correct
36 Correct 46 ms 16444 KB Output is correct
37 Correct 37 ms 16372 KB Output is correct
38 Correct 32 ms 16192 KB Output is correct
39 Correct 33 ms 16172 KB Output is correct
40 Correct 826 ms 17608 KB Output is correct
41 Correct 160 ms 16396 KB Output is correct
42 Correct 113 ms 16312 KB Output is correct
43 Correct 43 ms 17028 KB Output is correct
44 Correct 811 ms 17628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 10 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 9 ms 14288 KB Output is correct
6 Correct 9 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 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 7 ms 14288 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 8 ms 14368 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14328 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 10 ms 14288 KB Output is correct
20 Correct 7 ms 14416 KB Output is correct
21 Correct 7 ms 14412 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 12 ms 14364 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 9 ms 14476 KB Output is correct
28 Correct 10 ms 14420 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 24 ms 15660 KB Output is correct
31 Correct 11 ms 14928 KB Output is correct
32 Correct 28 ms 16580 KB Output is correct
33 Correct 31 ms 16420 KB Output is correct
34 Correct 1098 ms 17464 KB Output is correct
35 Correct 406 ms 16972 KB Output is correct
36 Correct 46 ms 16444 KB Output is correct
37 Correct 37 ms 16372 KB Output is correct
38 Correct 32 ms 16192 KB Output is correct
39 Correct 33 ms 16172 KB Output is correct
40 Correct 826 ms 17608 KB Output is correct
41 Correct 160 ms 16396 KB Output is correct
42 Correct 113 ms 16312 KB Output is correct
43 Correct 43 ms 17028 KB Output is correct
44 Correct 811 ms 17628 KB Output is correct
45 Incorrect 19 ms 17572 KB Wrong Answer[1]
46 Halted 0 ms 0 KB -