Submission #768182

# Submission time Handle Problem Language Result Execution time Memory
768182 2023-06-27T16:30:30 Z green_gold_dog Game (APIO22_game) C++17
60 / 100
4000 ms 121164 KB
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "game.h"
typedef int ll;

using namespace std;

vector<set<ll>> go_from, go_to;
vector<vector<bool>> go_from_k;
vector<bool> used;
vector<ll> be;
ll N, K;
bool b = false;

void init(int n, int k) {
	N = n;
	K = k;
	go_from_k.resize(n, vector<bool>(k, false));
	used.resize(n, false);
	go_from.resize(n);
	go_to.resize(n);
	for (ll i = 1; i < k; i++) {
		go_from[i].insert(i - 1);
		for (ll j = 0; j < i; j++) {
			go_from_k[i][j] = true;;
		}
	}
	for (ll i = 0; i < k - 1; i++) {
		go_to[i].insert(i + 1);
	}
}

void dfs(ll v, ll x) {
	if (go_from_k[v][x]) {
		return;
	}
	used[v] = true;
	be.push_back(v);
	if (v == x) {
		b = true;
		return;
	}
	go_from_k[v][x] = true;
	for (auto i : go_to[v]) {
		if (!used[i]) {
			dfs(i, x);
		}
	}
}

int add_teleporter(int u, int v) {
	go_from[v].insert(u);
	go_to[u].insert(v);
	for (ll i = 0; i < K; i++) {
		if (!go_from_k[u][i]) {
			continue;
		}
		dfs(v, i);
		for (auto v : be) {
			used[v] = false;
		}
		be.clear();
	}
	if (u < K) {
		dfs(v, u);
		for (auto v : be) {
			used[v] = false;
		}
		be.clear();
	}
	return b;
}

//int main() {
//	ll n, m, k;
//	cin >> n >> m >> k;
//	init(n, k);
//	for (ll i = 0; i < m; i++) {
//		ll a, b;
//		cin >> a >> b;
//		cout << add_teleporter(a, b) << '\n';
//	}
//}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 440 KB Output is correct
22 Correct 2 ms 476 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 5 ms 680 KB Output is correct
25 Correct 6 ms 804 KB Output is correct
26 Correct 7 ms 892 KB Output is correct
27 Correct 12 ms 848 KB Output is correct
28 Correct 4 ms 720 KB Output is correct
29 Correct 7 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 440 KB Output is correct
22 Correct 2 ms 476 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 5 ms 680 KB Output is correct
25 Correct 6 ms 804 KB Output is correct
26 Correct 7 ms 892 KB Output is correct
27 Correct 12 ms 848 KB Output is correct
28 Correct 4 ms 720 KB Output is correct
29 Correct 7 ms 880 KB Output is correct
30 Correct 29 ms 7968 KB Output is correct
31 Correct 20 ms 9296 KB Output is correct
32 Correct 46 ms 8352 KB Output is correct
33 Correct 18 ms 8088 KB Output is correct
34 Correct 883 ms 13400 KB Output is correct
35 Correct 452 ms 13428 KB Output is correct
36 Correct 137 ms 9896 KB Output is correct
37 Correct 568 ms 12520 KB Output is correct
38 Correct 565 ms 12772 KB Output is correct
39 Correct 540 ms 12944 KB Output is correct
40 Correct 812 ms 15148 KB Output is correct
41 Correct 398 ms 13468 KB Output is correct
42 Correct 279 ms 13384 KB Output is correct
43 Correct 1957 ms 14504 KB Output is correct
44 Correct 899 ms 13356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 440 KB Output is correct
22 Correct 2 ms 476 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 5 ms 680 KB Output is correct
25 Correct 6 ms 804 KB Output is correct
26 Correct 7 ms 892 KB Output is correct
27 Correct 12 ms 848 KB Output is correct
28 Correct 4 ms 720 KB Output is correct
29 Correct 7 ms 880 KB Output is correct
30 Correct 29 ms 7968 KB Output is correct
31 Correct 20 ms 9296 KB Output is correct
32 Correct 46 ms 8352 KB Output is correct
33 Correct 18 ms 8088 KB Output is correct
34 Correct 883 ms 13400 KB Output is correct
35 Correct 452 ms 13428 KB Output is correct
36 Correct 137 ms 9896 KB Output is correct
37 Correct 568 ms 12520 KB Output is correct
38 Correct 565 ms 12772 KB Output is correct
39 Correct 540 ms 12944 KB Output is correct
40 Correct 812 ms 15148 KB Output is correct
41 Correct 398 ms 13468 KB Output is correct
42 Correct 279 ms 13384 KB Output is correct
43 Correct 1957 ms 14504 KB Output is correct
44 Correct 899 ms 13356 KB Output is correct
45 Correct 386 ms 75792 KB Output is correct
46 Correct 71 ms 83280 KB Output is correct
47 Correct 100 ms 121164 KB Output is correct
48 Execution timed out 4035 ms 86956 KB Time limit exceeded
49 Halted 0 ms 0 KB -