Submission #816468

# Submission time Handle Problem Language Result Execution time Memory
816468 2023-08-09T05:12:14 Z 이동현(#10127) Game (APIO22_game) C++17
60 / 100
4000 ms 39356 KB
#include "game.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;

const int NS = (int)3e5 + 4;
int n, k;
vector<int> way[NS], wayb[NS];
int mn[NS], mx[NS];

void init(int N, int K) {
    n = N, k = K;
    for(int i = 0; i < k; ++i){
        mn[i] = mx[i] = i;
    }
    for(int i = k; i < n; ++i){
        mn[i] = (int)1e9, mx[i] = -1;
    }
}

int add_teleporter(int u, int v) {
    way[u].push_back(v);
    wayb[v].push_back(u);

    auto dfs1 = [&](auto&&self, int x)->int{
        for(auto&nxt:way[x]){
            if(mx[x] > mx[nxt]){
                mx[nxt] = mx[x];
                self(self, nxt);
            }
        }
        return mn[x];
    };
    dfs1(dfs1, u);

    auto dfs2 = [&](auto&&self, int x)->int{
        for(auto&nxt:wayb[x]){
            if(mn[x] < mn[nxt]){
                mn[nxt] = mn[x];
                self(self, nxt);
            }
        }
        return mx[x];
    };
    dfs2(dfs2, v);

    return mn[v] <= mx[u];
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14320 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14364 KB Output is correct
6 Correct 7 ms 14376 KB Output is correct
7 Correct 9 ms 14344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14320 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14364 KB Output is correct
6 Correct 7 ms 14376 KB Output is correct
7 Correct 9 ms 14344 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 9 ms 14288 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14384 KB Output is correct
16 Correct 9 ms 14360 KB Output is correct
17 Correct 8 ms 14340 KB Output is correct
18 Correct 9 ms 14400 KB Output is correct
19 Correct 8 ms 14412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14320 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14364 KB Output is correct
6 Correct 7 ms 14376 KB Output is correct
7 Correct 9 ms 14344 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 9 ms 14288 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14384 KB Output is correct
16 Correct 9 ms 14360 KB Output is correct
17 Correct 8 ms 14340 KB Output is correct
18 Correct 9 ms 14400 KB Output is correct
19 Correct 8 ms 14412 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 9 ms 14416 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 10 ms 14416 KB Output is correct
25 Correct 10 ms 14468 KB Output is correct
26 Correct 10 ms 14476 KB Output is correct
27 Correct 8 ms 14416 KB Output is correct
28 Correct 9 ms 14412 KB Output is correct
29 Correct 11 ms 14460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14320 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14364 KB Output is correct
6 Correct 7 ms 14376 KB Output is correct
7 Correct 9 ms 14344 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 9 ms 14288 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14384 KB Output is correct
16 Correct 9 ms 14360 KB Output is correct
17 Correct 8 ms 14340 KB Output is correct
18 Correct 9 ms 14400 KB Output is correct
19 Correct 8 ms 14412 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 9 ms 14416 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 10 ms 14416 KB Output is correct
25 Correct 10 ms 14468 KB Output is correct
26 Correct 10 ms 14476 KB Output is correct
27 Correct 8 ms 14416 KB Output is correct
28 Correct 9 ms 14412 KB Output is correct
29 Correct 11 ms 14460 KB Output is correct
30 Correct 25 ms 15704 KB Output is correct
31 Correct 13 ms 15020 KB Output is correct
32 Correct 22 ms 16780 KB Output is correct
33 Correct 23 ms 16480 KB Output is correct
34 Correct 882 ms 17216 KB Output is correct
35 Correct 333 ms 16808 KB Output is correct
36 Correct 32 ms 16408 KB Output is correct
37 Correct 32 ms 16444 KB Output is correct
38 Correct 28 ms 16172 KB Output is correct
39 Correct 30 ms 16172 KB Output is correct
40 Correct 696 ms 17308 KB Output is correct
41 Correct 145 ms 16484 KB Output is correct
42 Correct 101 ms 16360 KB Output is correct
43 Correct 43 ms 17344 KB Output is correct
44 Correct 649 ms 17468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14320 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14364 KB Output is correct
6 Correct 7 ms 14376 KB Output is correct
7 Correct 9 ms 14344 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 9 ms 14288 KB Output is correct
12 Correct 9 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14384 KB Output is correct
16 Correct 9 ms 14360 KB Output is correct
17 Correct 8 ms 14340 KB Output is correct
18 Correct 9 ms 14400 KB Output is correct
19 Correct 8 ms 14412 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 9 ms 14416 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 10 ms 14416 KB Output is correct
25 Correct 10 ms 14468 KB Output is correct
26 Correct 10 ms 14476 KB Output is correct
27 Correct 8 ms 14416 KB Output is correct
28 Correct 9 ms 14412 KB Output is correct
29 Correct 11 ms 14460 KB Output is correct
30 Correct 25 ms 15704 KB Output is correct
31 Correct 13 ms 15020 KB Output is correct
32 Correct 22 ms 16780 KB Output is correct
33 Correct 23 ms 16480 KB Output is correct
34 Correct 882 ms 17216 KB Output is correct
35 Correct 333 ms 16808 KB Output is correct
36 Correct 32 ms 16408 KB Output is correct
37 Correct 32 ms 16444 KB Output is correct
38 Correct 28 ms 16172 KB Output is correct
39 Correct 30 ms 16172 KB Output is correct
40 Correct 696 ms 17308 KB Output is correct
41 Correct 145 ms 16484 KB Output is correct
42 Correct 101 ms 16360 KB Output is correct
43 Correct 43 ms 17344 KB Output is correct
44 Correct 649 ms 17468 KB Output is correct
45 Correct 176 ms 27972 KB Output is correct
46 Correct 13 ms 17104 KB Output is correct
47 Correct 12 ms 17104 KB Output is correct
48 Correct 350 ms 39356 KB Output is correct
49 Correct 196 ms 35412 KB Output is correct
50 Execution timed out 4034 ms 30032 KB Time limit exceeded
51 Halted 0 ms 0 KB -