Submission #816458

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

int n, k;
vector<int> way[30004], wayb[30004];
int mn[30004], mx[30004];

void init(int N, int K) {
    n = N, k = K;
    assert(n <= 30000 && k <= 1000);
    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]){
            int go = 0;
            // if(mn[nxt] < mn[x]){
            //     mn[x] = mn[nxt], go = 1;
            // }
            if(mx[x] > mx[nxt]){
                mx[nxt] = mx[x], go = 1;
            }
            if(go) self(self, nxt);
        }
        return mn[x];
    };
    dfs1(dfs1, u);

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

    return mn[v] <= mx[u];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1724 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1724 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1728 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1616 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 1 ms 1616 KB Output is correct
17 Correct 1 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1724 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1728 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1616 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 1 ms 1616 KB Output is correct
17 Correct 1 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 2 ms 1744 KB Output is correct
21 Correct 1 ms 1616 KB Output is correct
22 Correct 1 ms 1744 KB Output is correct
23 Correct 2 ms 1744 KB Output is correct
24 Correct 4 ms 1724 KB Output is correct
25 Correct 3 ms 1744 KB Output is correct
26 Correct 5 ms 1772 KB Output is correct
27 Correct 2 ms 1744 KB Output is correct
28 Correct 3 ms 1744 KB Output is correct
29 Correct 3 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1724 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1728 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1616 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 1 ms 1616 KB Output is correct
17 Correct 1 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 2 ms 1744 KB Output is correct
21 Correct 1 ms 1616 KB Output is correct
22 Correct 1 ms 1744 KB Output is correct
23 Correct 2 ms 1744 KB Output is correct
24 Correct 4 ms 1724 KB Output is correct
25 Correct 3 ms 1744 KB Output is correct
26 Correct 5 ms 1772 KB Output is correct
27 Correct 2 ms 1744 KB Output is correct
28 Correct 3 ms 1744 KB Output is correct
29 Correct 3 ms 1744 KB Output is correct
30 Correct 14 ms 2972 KB Output is correct
31 Correct 5 ms 2332 KB Output is correct
32 Correct 18 ms 4100 KB Output is correct
33 Correct 12 ms 3804 KB Output is correct
34 Correct 940 ms 4520 KB Output is correct
35 Correct 311 ms 4112 KB Output is correct
36 Correct 27 ms 3780 KB Output is correct
37 Correct 38 ms 3728 KB Output is correct
38 Correct 29 ms 3524 KB Output is correct
39 Correct 24 ms 3536 KB Output is correct
40 Correct 695 ms 4648 KB Output is correct
41 Correct 136 ms 3760 KB Output is correct
42 Correct 90 ms 3648 KB Output is correct
43 Correct 29 ms 4592 KB Output is correct
44 Correct 619 ms 4516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1724 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1728 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1616 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 1 ms 1616 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 1 ms 1616 KB Output is correct
17 Correct 1 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 2 ms 1744 KB Output is correct
21 Correct 1 ms 1616 KB Output is correct
22 Correct 1 ms 1744 KB Output is correct
23 Correct 2 ms 1744 KB Output is correct
24 Correct 4 ms 1724 KB Output is correct
25 Correct 3 ms 1744 KB Output is correct
26 Correct 5 ms 1772 KB Output is correct
27 Correct 2 ms 1744 KB Output is correct
28 Correct 3 ms 1744 KB Output is correct
29 Correct 3 ms 1744 KB Output is correct
30 Correct 14 ms 2972 KB Output is correct
31 Correct 5 ms 2332 KB Output is correct
32 Correct 18 ms 4100 KB Output is correct
33 Correct 12 ms 3804 KB Output is correct
34 Correct 940 ms 4520 KB Output is correct
35 Correct 311 ms 4112 KB Output is correct
36 Correct 27 ms 3780 KB Output is correct
37 Correct 38 ms 3728 KB Output is correct
38 Correct 29 ms 3524 KB Output is correct
39 Correct 24 ms 3536 KB Output is correct
40 Correct 695 ms 4648 KB Output is correct
41 Correct 136 ms 3760 KB Output is correct
42 Correct 90 ms 3648 KB Output is correct
43 Correct 29 ms 4592 KB Output is correct
44 Correct 619 ms 4516 KB Output is correct
45 Runtime error 3 ms 3224 KB Execution killed with signal 6
46 Halted 0 ms 0 KB -