Submission #587387

# Submission time Handle Problem Language Result Execution time Memory
587387 2022-07-01T18:25:12 Z mohammad_kilani Game (APIO22_game) C++17
60 / 100
4000 ms 42544 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

#define oo 1000000010

vector< vector< int >  > g , g2;

vector< int > mn , mx , last , last2;

int n , k;

void init(int n, int k) {
	::n = n;
	::k = k;
	g.resize(n);
	g2.resize(n);
	mn.resize(n);
	mx.resize(n);
	for(int i = 0 ;i < k;i++){
		mn[i] = mx[i] = i;
	}
	for(int i = k ;i < n;i++){
		mn[i] = oo;
		mx[i] = -oo;
	}
}

void CheckMax(int u){
	if(mx[u] == -oo) return;
	for(int i = 0 ;i < (int)g[u].size();i++){
		if(mx[g[u][i]] < mx[u]){
			mx[g[u][i]] = mx[u];
			CheckMax(g[u][i]);
		}
	}
}

void CheckMin(int u){
	if(mn[u] == oo) return;

	for(int i = 0 ;i < (int)g2[u].size();i++){
		if(mn[g2[u][i]] > mn[u]){
			mn[g2[u][i]] = mn[u];
			CheckMin(g2[u][i]);
		}
	}
}

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

	//mx[v] 

	g[u].push_back(v);
	if(mx[v] < mx[u])
		CheckMax(u);

	g2[v].push_back(u);
	if(mn[u] > mn[v])
		CheckMin(v);

	if(u < k) u = v;
	if(mn[u] <= mx[u] && (mx[u] != k)){
		return 1;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 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 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 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 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 5 ms 336 KB Output is correct
25 Correct 4 ms 436 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 368 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 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 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 5 ms 336 KB Output is correct
25 Correct 4 ms 436 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 368 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 16 ms 3024 KB Output is correct
31 Correct 4 ms 2256 KB Output is correct
32 Correct 18 ms 4380 KB Output is correct
33 Correct 17 ms 3920 KB Output is correct
34 Correct 1119 ms 5112 KB Output is correct
35 Correct 378 ms 4340 KB Output is correct
36 Correct 30 ms 3756 KB Output is correct
37 Correct 32 ms 3736 KB Output is correct
38 Correct 23 ms 3556 KB Output is correct
39 Correct 28 ms 3556 KB Output is correct
40 Correct 909 ms 5440 KB Output is correct
41 Correct 164 ms 3872 KB Output is correct
42 Correct 109 ms 3772 KB Output is correct
43 Correct 40 ms 5256 KB Output is correct
44 Correct 813 ms 5288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 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 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 5 ms 336 KB Output is correct
25 Correct 4 ms 436 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 2 ms 368 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 16 ms 3024 KB Output is correct
31 Correct 4 ms 2256 KB Output is correct
32 Correct 18 ms 4380 KB Output is correct
33 Correct 17 ms 3920 KB Output is correct
34 Correct 1119 ms 5112 KB Output is correct
35 Correct 378 ms 4340 KB Output is correct
36 Correct 30 ms 3756 KB Output is correct
37 Correct 32 ms 3736 KB Output is correct
38 Correct 23 ms 3556 KB Output is correct
39 Correct 28 ms 3556 KB Output is correct
40 Correct 909 ms 5440 KB Output is correct
41 Correct 164 ms 3872 KB Output is correct
42 Correct 109 ms 3772 KB Output is correct
43 Correct 40 ms 5256 KB Output is correct
44 Correct 813 ms 5288 KB Output is correct
45 Correct 233 ms 28104 KB Output is correct
46 Correct 13 ms 17104 KB Output is correct
47 Correct 13 ms 17104 KB Output is correct
48 Correct 363 ms 42544 KB Output is correct
49 Correct 260 ms 35628 KB Output is correct
50 Execution timed out 4026 ms 33164 KB Time limit exceeded
51 Halted 0 ms 0 KB -