Submission #576275

# Submission time Handle Problem Language Result Execution time Memory
576275 2022-06-12T21:49:22 Z lunchbox Game (APIO22_game) C++17
100 / 100
1228 ms 55908 KB
// #include "game.h"
#include <bits/stdc++.h>
using namespace std;

template<class T> using vec = vector<T>;

const int N = 3e5 + 2;

int n, k, tt[N][2];
vec<int> g[N][2];

void init(int n_, int k_) {
    n = n_ + 2, k = k_ + 2;
    for (int i = 0; i < n; i++)
        if (i < k)
            tt[i][0] = tt[i][1] = i;
        else
            tt[i][0] = 0, tt[i][1] = k - 1;
}

bool dfs(int i, int j, int t) {
    if (j < k)
        return 0;

    int p = tt[j][t];

    tt[j][t] = (t == 0 ? max(tt[i][t], tt[j][t]) : min(tt[i][t], tt[j][t]));
    if (tt[j][1] <= tt[j][0])
        return 1;
    if (__builtin_clz(p ^ tt[j][t ^ 1]) < __builtin_clz(tt[j][t] ^ tt[j][t ^ 1])) {
        for (int v : g[j][0])
            if (dfs(j, v, 0))
                return 1;
        for (int v : g[j][1])
            if (dfs(j, v, 1))
                return 1;
    }
    return 0;
}

int add_teleporter(int i, int j) {
    i = i < k - 2 ? i + 1 : i + 2;
    j = j < k - 2 ? j + 1 : j + 2;
    
    if (i < k && j < k)
        return i >= j;
    g[i][0].push_back(j), g[j][1].push_back(i);
    return dfs(i, j, 0) || dfs(j, i, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14348 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14348 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14348 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 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 8 ms 14288 KB Output is correct
15 Correct 7 ms 14320 KB Output is correct
16 Correct 8 ms 14360 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 14344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14348 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14348 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 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 8 ms 14288 KB Output is correct
15 Correct 7 ms 14320 KB Output is correct
16 Correct 8 ms 14360 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 14344 KB Output is correct
20 Correct 8 ms 14424 KB Output is correct
21 Correct 9 ms 14412 KB Output is correct
22 Correct 9 ms 14412 KB Output is correct
23 Correct 10 ms 14416 KB Output is correct
24 Correct 9 ms 14380 KB Output is correct
25 Correct 11 ms 14444 KB Output is correct
26 Correct 10 ms 14412 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 8 ms 14416 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 14348 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14348 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 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 8 ms 14288 KB Output is correct
15 Correct 7 ms 14320 KB Output is correct
16 Correct 8 ms 14360 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 14344 KB Output is correct
20 Correct 8 ms 14424 KB Output is correct
21 Correct 9 ms 14412 KB Output is correct
22 Correct 9 ms 14412 KB Output is correct
23 Correct 10 ms 14416 KB Output is correct
24 Correct 9 ms 14380 KB Output is correct
25 Correct 11 ms 14444 KB Output is correct
26 Correct 10 ms 14412 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 8 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 22 ms 15752 KB Output is correct
31 Correct 11 ms 14928 KB Output is correct
32 Correct 23 ms 17096 KB Output is correct
33 Correct 24 ms 16428 KB Output is correct
34 Correct 32 ms 19120 KB Output is correct
35 Correct 40 ms 17352 KB Output is correct
36 Correct 35 ms 16460 KB Output is correct
37 Correct 33 ms 16428 KB Output is correct
38 Correct 35 ms 16212 KB Output is correct
39 Correct 32 ms 16244 KB Output is correct
40 Correct 47 ms 19212 KB Output is correct
41 Correct 54 ms 16944 KB Output is correct
42 Correct 33 ms 16684 KB Output is correct
43 Correct 50 ms 17320 KB Output is correct
44 Correct 43 ms 16952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14348 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 8 ms 14348 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 8 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 8 ms 14288 KB Output is correct
15 Correct 7 ms 14320 KB Output is correct
16 Correct 8 ms 14360 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 14344 KB Output is correct
20 Correct 8 ms 14424 KB Output is correct
21 Correct 9 ms 14412 KB Output is correct
22 Correct 9 ms 14412 KB Output is correct
23 Correct 10 ms 14416 KB Output is correct
24 Correct 9 ms 14380 KB Output is correct
25 Correct 11 ms 14444 KB Output is correct
26 Correct 10 ms 14412 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 8 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 22 ms 15752 KB Output is correct
31 Correct 11 ms 14928 KB Output is correct
32 Correct 23 ms 17096 KB Output is correct
33 Correct 24 ms 16428 KB Output is correct
34 Correct 32 ms 19120 KB Output is correct
35 Correct 40 ms 17352 KB Output is correct
36 Correct 35 ms 16460 KB Output is correct
37 Correct 33 ms 16428 KB Output is correct
38 Correct 35 ms 16212 KB Output is correct
39 Correct 32 ms 16244 KB Output is correct
40 Correct 47 ms 19212 KB Output is correct
41 Correct 54 ms 16944 KB Output is correct
42 Correct 33 ms 16684 KB Output is correct
43 Correct 50 ms 17320 KB Output is correct
44 Correct 43 ms 16952 KB Output is correct
45 Correct 234 ms 27976 KB Output is correct
46 Correct 16 ms 17104 KB Output is correct
47 Correct 13 ms 17104 KB Output is correct
48 Correct 297 ms 42516 KB Output is correct
49 Correct 286 ms 35416 KB Output is correct
50 Correct 680 ms 45576 KB Output is correct
51 Correct 858 ms 42016 KB Output is correct
52 Correct 493 ms 35440 KB Output is correct
53 Correct 696 ms 35624 KB Output is correct
54 Correct 698 ms 35184 KB Output is correct
55 Correct 1018 ms 35528 KB Output is correct
56 Correct 1018 ms 35432 KB Output is correct
57 Correct 467 ms 29304 KB Output is correct
58 Correct 449 ms 29468 KB Output is correct
59 Correct 515 ms 29580 KB Output is correct
60 Correct 474 ms 29372 KB Output is correct
61 Correct 542 ms 29020 KB Output is correct
62 Correct 522 ms 37104 KB Output is correct
63 Correct 489 ms 33756 KB Output is correct
64 Correct 1228 ms 55908 KB Output is correct
65 Correct 534 ms 34972 KB Output is correct
66 Correct 448 ms 30916 KB Output is correct
67 Correct 859 ms 39972 KB Output is correct
68 Correct 211 ms 26184 KB Output is correct
69 Correct 54 ms 20124 KB Output is correct
70 Correct 773 ms 38708 KB Output is correct
71 Correct 302 ms 28204 KB Output is correct
72 Correct 219 ms 24108 KB Output is correct
73 Correct 634 ms 36124 KB Output is correct
74 Correct 1195 ms 34888 KB Output is correct
75 Correct 1000 ms 42940 KB Output is correct
76 Correct 1078 ms 42000 KB Output is correct