답안 #713001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713001 2023-03-20T19:07:00 Z piOOE 게임 (APIO22_game) C++17
60 / 100
1229 ms 59312 KB
#include "game.h"
#include <bits/stdc++.h>

constexpr int N = 3e5 + 7, B = 8, inf = 1e9 + 7;

int fromMe[N], toMe[N], Mid[N], save[N][2], n, k; //smallest from me, biggest to me

std::vector<int> adj[N], rev[N];

bool found = false;


void relax(int v) {
    if (v >= k && fromMe[v] <= toMe[v]) {
        found = true;
    }

    Mid[v] = (fromMe[v] + toMe[v]) >> 1;
}

void init(int n, int k) {
    ::n = n, ::k = k;

    for (int i = 0; i < n; ++i) {
        if (i >= k) {
            fromMe[i] = k, toMe[i] = -1;
        } else {
            fromMe[i] = toMe[i] = i;
        }

        save[i][0] = inf, save[i][1] = -inf;
        relax(i);
    }
}

void dfs2(int v, int x);

void dfs1(int v, int x) {
    if (found || v < k || fromMe[v] <= x) {
        return;
    }

    if (Mid[v] + 1 < x) {
        save[v][0] = std::min(save[v][0], x);
        return;
    }

    fromMe[v] = x;
    relax(v);

    for (int to : rev[v]) {
        dfs1(to, x);
    }

    dfs2(v, save[v][1]);
}

void dfs2(int v, int x) {
    if (found || v < k || toMe[v] >= x) {
        return;
    }

    if (Mid[v] - 1 > x) {
        save[v][1] = std::max(save[v][1], x);
        return;
    }

    toMe[v] = x;
    relax(v);

    for (int to : adj[v]) {
        dfs2(to, x);
    }

    dfs1(v, save[v][0]);
}

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

    adj[u].push_back(v);
    rev[v].push_back(u);

    dfs1(u, fromMe[v]);
    dfs2(v, toMe[u]);

    return found;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14416 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 7 ms 14416 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14416 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14416 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 7 ms 14416 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14416 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 8 ms 14408 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14388 KB Output is correct
14 Correct 8 ms 14416 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14416 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14416 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14416 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 7 ms 14416 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14416 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 8 ms 14408 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14388 KB Output is correct
14 Correct 8 ms 14416 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14416 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14416 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14396 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 8 ms 14416 KB Output is correct
25 Correct 12 ms 14488 KB Output is correct
26 Correct 9 ms 14440 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 8 ms 14424 KB Output is correct
29 Correct 10 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14416 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 7 ms 14416 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14416 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 8 ms 14408 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14388 KB Output is correct
14 Correct 8 ms 14416 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14416 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14416 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14396 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 8 ms 14416 KB Output is correct
25 Correct 12 ms 14488 KB Output is correct
26 Correct 9 ms 14440 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 8 ms 14424 KB Output is correct
29 Correct 10 ms 14416 KB Output is correct
30 Correct 24 ms 16100 KB Output is correct
31 Correct 11 ms 15312 KB Output is correct
32 Correct 31 ms 17496 KB Output is correct
33 Correct 26 ms 16820 KB Output is correct
34 Correct 35 ms 19528 KB Output is correct
35 Correct 40 ms 17736 KB Output is correct
36 Correct 42 ms 16852 KB Output is correct
37 Correct 40 ms 16836 KB Output is correct
38 Correct 42 ms 16500 KB Output is correct
39 Correct 33 ms 16560 KB Output is correct
40 Correct 50 ms 19384 KB Output is correct
41 Correct 36 ms 17352 KB Output is correct
42 Correct 35 ms 16988 KB Output is correct
43 Correct 49 ms 17616 KB Output is correct
44 Correct 42 ms 17576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14416 KB Output is correct
2 Correct 9 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 7 ms 14416 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14416 KB Output is correct
7 Correct 8 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 8 ms 14408 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14388 KB Output is correct
14 Correct 8 ms 14416 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14416 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14416 KB Output is correct
19 Correct 10 ms 14416 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14416 KB Output is correct
22 Correct 8 ms 14396 KB Output is correct
23 Correct 9 ms 14416 KB Output is correct
24 Correct 8 ms 14416 KB Output is correct
25 Correct 12 ms 14488 KB Output is correct
26 Correct 9 ms 14440 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 8 ms 14424 KB Output is correct
29 Correct 10 ms 14416 KB Output is correct
30 Correct 24 ms 16100 KB Output is correct
31 Correct 11 ms 15312 KB Output is correct
32 Correct 31 ms 17496 KB Output is correct
33 Correct 26 ms 16820 KB Output is correct
34 Correct 35 ms 19528 KB Output is correct
35 Correct 40 ms 17736 KB Output is correct
36 Correct 42 ms 16852 KB Output is correct
37 Correct 40 ms 16836 KB Output is correct
38 Correct 42 ms 16500 KB Output is correct
39 Correct 33 ms 16560 KB Output is correct
40 Correct 50 ms 19384 KB Output is correct
41 Correct 36 ms 17352 KB Output is correct
42 Correct 35 ms 16988 KB Output is correct
43 Correct 49 ms 17616 KB Output is correct
44 Correct 42 ms 17576 KB Output is correct
45 Correct 241 ms 31528 KB Output is correct
46 Correct 16 ms 20688 KB Output is correct
47 Correct 18 ms 20552 KB Output is correct
48 Correct 366 ms 44976 KB Output is correct
49 Correct 276 ms 38956 KB Output is correct
50 Correct 423 ms 49048 KB Output is correct
51 Correct 695 ms 45528 KB Output is correct
52 Correct 578 ms 38924 KB Output is correct
53 Correct 641 ms 38964 KB Output is correct
54 Correct 749 ms 38864 KB Output is correct
55 Correct 1043 ms 39212 KB Output is correct
56 Correct 1229 ms 39000 KB Output is correct
57 Correct 446 ms 32936 KB Output is correct
58 Correct 443 ms 32984 KB Output is correct
59 Correct 460 ms 33000 KB Output is correct
60 Correct 532 ms 32844 KB Output is correct
61 Correct 544 ms 32544 KB Output is correct
62 Correct 367 ms 40700 KB Output is correct
63 Correct 253 ms 37268 KB Output is correct
64 Correct 801 ms 59312 KB Output is correct
65 Correct 420 ms 38624 KB Output is correct
66 Correct 331 ms 34508 KB Output is correct
67 Correct 705 ms 43480 KB Output is correct
68 Correct 232 ms 29744 KB Output is correct
69 Correct 67 ms 23588 KB Output is correct
70 Incorrect 662 ms 42096 KB Wrong Answer[1]
71 Halted 0 ms 0 KB -