# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
699272 |
2023-02-16T10:42:49 Z |
KoD |
Game (APIO22_game) |
C++17 |
|
1528 ms |
68032 KB |
#include "game.h"
#include <algorithm>
#include <utility>
#include <vector>
namespace kod {
using namespace std;
int n, k;
vector<int> l, r;
vector<vector<int>> in, out;
int get_level(const int u) { return l[u] >= r[u] ? 0 : 32 - __builtin_clz(l[u] ^ r[u]); }
bool check_vertex(const int u);
bool check_edge(const int u, const int v);
bool check_vertex(const int x) {
for (const int y : out[x]) {
if (check_edge(x, y)) {
return true;
}
}
for (const int y : in[x]) {
if (check_edge(y, x)) {
return true;
}
}
return false;
}
bool check_edge(const int u, const int v) {
const int u0 = get_level(u);
const int v0 = get_level(v);
r[u] = min(r[u], v <= k ? v : r[v]);
l[v] = max(l[v], u <= k ? u : l[u]);
const int u1 = get_level(u);
const int v1 = get_level(v);
if (u1 == 0 or v1 == 0) return true;
if (u1 < u0 and check_vertex(u)) return true;
if (v1 < v0 and check_vertex(v)) return true;
return false;
}
int add_edge(const int u, const int v) {
in[v].push_back(u);
out[u].push_back(v);
return check_edge(u, v);
}
void init(const int n_, const int k_) {
n = n_;
k = k_;
l.resize(n + 1, 0);
r.resize(n + 1, k + 1);
in.resize(n + 1);
out.resize(n + 1);
for (int i = 1; i <= k - 1; ++i) {
in[i + 1].push_back(i);
out[i].push_back(i + 1);
r[i] = i + 1;
l[i + 1] = i;
}
}
} // namespace kod
void init(int n, int k) { kod::init(n, k); }
int add_teleporter(int u, int v) { return kod::add_edge(u + 1, v + 1); }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
276 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
276 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 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 |
0 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 |
276 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 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 |
0 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 |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
396 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
276 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 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 |
0 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 |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
396 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
19 ms |
3072 KB |
Output is correct |
31 |
Correct |
5 ms |
2384 KB |
Output is correct |
32 |
Correct |
18 ms |
5064 KB |
Output is correct |
33 |
Correct |
16 ms |
3808 KB |
Output is correct |
34 |
Correct |
29 ms |
7816 KB |
Output is correct |
35 |
Correct |
41 ms |
5192 KB |
Output is correct |
36 |
Correct |
30 ms |
3768 KB |
Output is correct |
37 |
Correct |
26 ms |
3788 KB |
Output is correct |
38 |
Correct |
26 ms |
3528 KB |
Output is correct |
39 |
Correct |
26 ms |
3604 KB |
Output is correct |
40 |
Correct |
40 ms |
7680 KB |
Output is correct |
41 |
Correct |
33 ms |
4760 KB |
Output is correct |
42 |
Correct |
30 ms |
4248 KB |
Output is correct |
43 |
Correct |
38 ms |
5192 KB |
Output is correct |
44 |
Correct |
47 ms |
4936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
276 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 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 |
0 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 |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
396 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
19 ms |
3072 KB |
Output is correct |
31 |
Correct |
5 ms |
2384 KB |
Output is correct |
32 |
Correct |
18 ms |
5064 KB |
Output is correct |
33 |
Correct |
16 ms |
3808 KB |
Output is correct |
34 |
Correct |
29 ms |
7816 KB |
Output is correct |
35 |
Correct |
41 ms |
5192 KB |
Output is correct |
36 |
Correct |
30 ms |
3768 KB |
Output is correct |
37 |
Correct |
26 ms |
3788 KB |
Output is correct |
38 |
Correct |
26 ms |
3528 KB |
Output is correct |
39 |
Correct |
26 ms |
3604 KB |
Output is correct |
40 |
Correct |
40 ms |
7680 KB |
Output is correct |
41 |
Correct |
33 ms |
4760 KB |
Output is correct |
42 |
Correct |
30 ms |
4248 KB |
Output is correct |
43 |
Correct |
38 ms |
5192 KB |
Output is correct |
44 |
Correct |
47 ms |
4936 KB |
Output is correct |
45 |
Correct |
239 ms |
28096 KB |
Output is correct |
46 |
Correct |
14 ms |
17224 KB |
Output is correct |
47 |
Correct |
12 ms |
17128 KB |
Output is correct |
48 |
Correct |
298 ms |
49836 KB |
Output is correct |
49 |
Correct |
279 ms |
35528 KB |
Output is correct |
50 |
Correct |
777 ms |
57464 KB |
Output is correct |
51 |
Correct |
1008 ms |
46788 KB |
Output is correct |
52 |
Correct |
567 ms |
35480 KB |
Output is correct |
53 |
Correct |
743 ms |
35848 KB |
Output is correct |
54 |
Correct |
728 ms |
35768 KB |
Output is correct |
55 |
Correct |
1131 ms |
35736 KB |
Output is correct |
56 |
Correct |
1211 ms |
35776 KB |
Output is correct |
57 |
Correct |
483 ms |
35760 KB |
Output is correct |
58 |
Correct |
467 ms |
35964 KB |
Output is correct |
59 |
Correct |
477 ms |
35924 KB |
Output is correct |
60 |
Correct |
494 ms |
36124 KB |
Output is correct |
61 |
Correct |
538 ms |
35816 KB |
Output is correct |
62 |
Correct |
559 ms |
43244 KB |
Output is correct |
63 |
Correct |
514 ms |
39924 KB |
Output is correct |
64 |
Correct |
1319 ms |
68032 KB |
Output is correct |
65 |
Correct |
612 ms |
37396 KB |
Output is correct |
66 |
Correct |
499 ms |
33516 KB |
Output is correct |
67 |
Correct |
988 ms |
42996 KB |
Output is correct |
68 |
Correct |
238 ms |
29452 KB |
Output is correct |
69 |
Correct |
65 ms |
23372 KB |
Output is correct |
70 |
Correct |
924 ms |
45644 KB |
Output is correct |
71 |
Correct |
313 ms |
30136 KB |
Output is correct |
72 |
Correct |
234 ms |
26116 KB |
Output is correct |
73 |
Correct |
803 ms |
40192 KB |
Output is correct |
74 |
Correct |
1276 ms |
36056 KB |
Output is correct |
75 |
Correct |
1232 ms |
50024 KB |
Output is correct |
76 |
Correct |
1528 ms |
50116 KB |
Output is correct |