답안 #713000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713000 2023-03-20T19:06:06 Z piOOE 게임 (APIO22_game) C++17
60 / 100
4000 ms 59468 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]  + 50 < 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] - 50 > 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 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 7 ms 14416 KB Output is correct
6 Correct 7 ms 14416 KB Output is correct
7 Correct 7 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 7 ms 14416 KB Output is correct
6 Correct 7 ms 14416 KB Output is correct
7 Correct 7 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 8 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 9 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 7 ms 14416 KB Output is correct
15 Correct 7 ms 14432 KB Output is correct
16 Correct 8 ms 14372 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14368 KB Output is correct
19 Correct 7 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 7 ms 14416 KB Output is correct
6 Correct 7 ms 14416 KB Output is correct
7 Correct 7 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 8 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 9 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 7 ms 14416 KB Output is correct
15 Correct 7 ms 14432 KB Output is correct
16 Correct 8 ms 14372 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14368 KB Output is correct
19 Correct 7 ms 14416 KB Output is correct
20 Correct 8 ms 14444 KB Output is correct
21 Correct 7 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 11 ms 14544 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 10 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 7 ms 14416 KB Output is correct
6 Correct 7 ms 14416 KB Output is correct
7 Correct 7 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 8 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 9 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 7 ms 14416 KB Output is correct
15 Correct 7 ms 14432 KB Output is correct
16 Correct 8 ms 14372 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14368 KB Output is correct
19 Correct 7 ms 14416 KB Output is correct
20 Correct 8 ms 14444 KB Output is correct
21 Correct 7 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 11 ms 14544 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 10 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 24 ms 16068 KB Output is correct
31 Correct 12 ms 15312 KB Output is correct
32 Correct 25 ms 17096 KB Output is correct
33 Correct 25 ms 16840 KB Output is correct
34 Correct 148 ms 19560 KB Output is correct
35 Correct 75 ms 17900 KB Output is correct
36 Correct 41 ms 16840 KB Output is correct
37 Correct 35 ms 16776 KB Output is correct
38 Correct 34 ms 16524 KB Output is correct
39 Correct 33 ms 16584 KB Output is correct
40 Correct 163 ms 19484 KB Output is correct
41 Correct 51 ms 17292 KB Output is correct
42 Correct 44 ms 17044 KB Output is correct
43 Correct 48 ms 17652 KB Output is correct
44 Correct 94 ms 17604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 8 ms 14416 KB Output is correct
5 Correct 7 ms 14416 KB Output is correct
6 Correct 7 ms 14416 KB Output is correct
7 Correct 7 ms 14416 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 8 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 9 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Correct 8 ms 14416 KB Output is correct
14 Correct 7 ms 14416 KB Output is correct
15 Correct 7 ms 14432 KB Output is correct
16 Correct 8 ms 14372 KB Output is correct
17 Correct 8 ms 14416 KB Output is correct
18 Correct 8 ms 14368 KB Output is correct
19 Correct 7 ms 14416 KB Output is correct
20 Correct 8 ms 14444 KB Output is correct
21 Correct 7 ms 14416 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 9 ms 14416 KB Output is correct
25 Correct 11 ms 14544 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 9 ms 14416 KB Output is correct
28 Correct 10 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 24 ms 16068 KB Output is correct
31 Correct 12 ms 15312 KB Output is correct
32 Correct 25 ms 17096 KB Output is correct
33 Correct 25 ms 16840 KB Output is correct
34 Correct 148 ms 19560 KB Output is correct
35 Correct 75 ms 17900 KB Output is correct
36 Correct 41 ms 16840 KB Output is correct
37 Correct 35 ms 16776 KB Output is correct
38 Correct 34 ms 16524 KB Output is correct
39 Correct 33 ms 16584 KB Output is correct
40 Correct 163 ms 19484 KB Output is correct
41 Correct 51 ms 17292 KB Output is correct
42 Correct 44 ms 17044 KB Output is correct
43 Correct 48 ms 17652 KB Output is correct
44 Correct 94 ms 17604 KB Output is correct
45 Correct 248 ms 31532 KB Output is correct
46 Correct 18 ms 20636 KB Output is correct
47 Correct 15 ms 20564 KB Output is correct
48 Correct 329 ms 45036 KB Output is correct
49 Correct 276 ms 39012 KB Output is correct
50 Correct 3176 ms 49060 KB Output is correct
51 Correct 2312 ms 45608 KB Output is correct
52 Correct 727 ms 38880 KB Output is correct
53 Correct 869 ms 39056 KB Output is correct
54 Correct 831 ms 38856 KB Output is correct
55 Correct 3750 ms 39196 KB Output is correct
56 Correct 3600 ms 38952 KB Output is correct
57 Correct 470 ms 32992 KB Output is correct
58 Correct 446 ms 32992 KB Output is correct
59 Correct 463 ms 33032 KB Output is correct
60 Correct 561 ms 33064 KB Output is correct
61 Correct 594 ms 32648 KB Output is correct
62 Correct 1711 ms 40624 KB Output is correct
63 Correct 1668 ms 37280 KB Output is correct
64 Execution timed out 4027 ms 59468 KB Time limit exceeded
65 Halted 0 ms 0 KB -