답안 #725332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725332 2023-04-17T09:49:17 Z SanguineChameleon 게임 (APIO22_game) C++17
60 / 100
4000 ms 39408 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

const int maxN = 3e5 + 20;
const int block = 500;
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;
	for (int i = 0; i < k; i++) {
		max_in[i] = i - 1;
		min_out[i] = i;
	}
	for (int i = k; i < n; i++) {
		max_in[i] = -1;
		min_out[i] = k;
	}
}

void update_in(int u, int val) {
	if (done) {
		return;
	}
	if (val <= max_in[u]) {
		return;
	}
	bool update = ((max_in[u] / block) < (val / block) || (max_in[u] / block) == (min_out[u] / block));
	max_in[u] = val;
	if (max_in[u] >= min_out[u]) {
		done = true;
		return;
	}
	if (update) {
		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;
	}
	bool update = ((min_out[u] / block) > (val / block) || (max_in[u] / block) == (min_out[u] / block));
	min_out[u] = val;
	if (max_in[u] >= min_out[u]) {
		done = true;
		return;
	}
	if (update) {
		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)));
	update_out(u, min_out[v]);
	adj1[u].push_back(v);
	adj2[v].push_back(u);
	return done;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 8 ms 14368 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 14348 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 8 ms 14368 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 14348 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14272 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 9 ms 14516 KB Output is correct
14 Correct 9 ms 14288 KB Output is correct
15 Correct 8 ms 14344 KB Output is correct
16 Correct 8 ms 14396 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 8 ms 14368 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 14348 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14272 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 9 ms 14516 KB Output is correct
14 Correct 9 ms 14288 KB Output is correct
15 Correct 8 ms 14344 KB Output is correct
16 Correct 8 ms 14396 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14320 KB Output is correct
20 Correct 8 ms 14544 KB Output is correct
21 Correct 8 ms 14288 KB Output is correct
22 Correct 8 ms 14436 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 11 ms 14416 KB Output is correct
25 Correct 11 ms 14416 KB Output is correct
26 Correct 11 ms 14436 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14336 KB Output is correct
29 Correct 10 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 8 ms 14368 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 14348 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14272 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 9 ms 14516 KB Output is correct
14 Correct 9 ms 14288 KB Output is correct
15 Correct 8 ms 14344 KB Output is correct
16 Correct 8 ms 14396 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14320 KB Output is correct
20 Correct 8 ms 14544 KB Output is correct
21 Correct 8 ms 14288 KB Output is correct
22 Correct 8 ms 14436 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 11 ms 14416 KB Output is correct
25 Correct 11 ms 14416 KB Output is correct
26 Correct 11 ms 14436 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14336 KB Output is correct
29 Correct 10 ms 14416 KB Output is correct
30 Correct 25 ms 15688 KB Output is correct
31 Correct 12 ms 14988 KB Output is correct
32 Correct 37 ms 16604 KB Output is correct
33 Correct 27 ms 16428 KB Output is correct
34 Correct 51 ms 17252 KB Output is correct
35 Correct 45 ms 16840 KB Output is correct
36 Correct 44 ms 16440 KB Output is correct
37 Correct 37 ms 16364 KB Output is correct
38 Correct 41 ms 16400 KB Output is correct
39 Correct 38 ms 16280 KB Output is correct
40 Correct 41 ms 17456 KB Output is correct
41 Correct 35 ms 16516 KB Output is correct
42 Correct 41 ms 16340 KB Output is correct
43 Correct 64 ms 17012 KB Output is correct
44 Correct 187 ms 17376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 8 ms 14368 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 14348 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 8 ms 14272 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 9 ms 14516 KB Output is correct
14 Correct 9 ms 14288 KB Output is correct
15 Correct 8 ms 14344 KB Output is correct
16 Correct 8 ms 14396 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14320 KB Output is correct
20 Correct 8 ms 14544 KB Output is correct
21 Correct 8 ms 14288 KB Output is correct
22 Correct 8 ms 14436 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 11 ms 14416 KB Output is correct
25 Correct 11 ms 14416 KB Output is correct
26 Correct 11 ms 14436 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14336 KB Output is correct
29 Correct 10 ms 14416 KB Output is correct
30 Correct 25 ms 15688 KB Output is correct
31 Correct 12 ms 14988 KB Output is correct
32 Correct 37 ms 16604 KB Output is correct
33 Correct 27 ms 16428 KB Output is correct
34 Correct 51 ms 17252 KB Output is correct
35 Correct 45 ms 16840 KB Output is correct
36 Correct 44 ms 16440 KB Output is correct
37 Correct 37 ms 16364 KB Output is correct
38 Correct 41 ms 16400 KB Output is correct
39 Correct 38 ms 16280 KB Output is correct
40 Correct 41 ms 17456 KB Output is correct
41 Correct 35 ms 16516 KB Output is correct
42 Correct 41 ms 16340 KB Output is correct
43 Correct 64 ms 17012 KB Output is correct
44 Correct 187 ms 17376 KB Output is correct
45 Correct 240 ms 28084 KB Output is correct
46 Correct 18 ms 17164 KB Output is correct
47 Correct 15 ms 17104 KB Output is correct
48 Correct 377 ms 39408 KB Output is correct
49 Correct 319 ms 35528 KB Output is correct
50 Execution timed out 4011 ms 33308 KB Time limit exceeded
51 Halted 0 ms 0 KB -