Submission #580201

# Submission time Handle Problem Language Result Execution time Memory
580201 2022-06-20T17:28:45 Z pawned Game (APIO22_game) C++17
60 / 100
4000 ms 47176 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

int N, K;

vi adj[300005];
vi rev[300005];

ii range[300005];

void init(int n, int k) {
    N = n;
    K = k;
    for (int i = 1; i < K; i++) {
        adj[i].pb(i + 1);
        rev[i + 1].pb(i);
        range[i] = {i, i};
    }
    range[K] = {K, K};
    for (int i = K + 1; i <= N; i++) {
        range[i] = {0, K + 1};
    }
}

bool dfs(int u, int v) {
    if (range[u].se <= range[v].fi) // rip
        return false;
    if (range[u].fi >= range[v].se) // good
        return true;
    if (range[v].fi < range[u].fi) {
        range[v].fi = range[u].fi;
        for (int i : adj[v]) {
            if (dfs(v, i))
                return true;
        }
    }
    if (range[u].se > range[v].se) {
        range[u].se = range[v].se;
        for (int i : rev[u]) {
            if (dfs(i, u))
                return true;
        }
    }
    return false;
}

int add_teleporter(int u, int v) {
    u++; v++;
    if (u >= v && u <= K)
        return 1;
    if (u == v)
        return 0;
    adj[u].pb(v);
    rev[v].pb(u);
    return dfs(u, v);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14368 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14368 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14308 KB Output is correct
13 Correct 10 ms 14392 KB Output is correct
14 Correct 8 ms 14280 KB Output is correct
15 Correct 8 ms 14400 KB Output is correct
16 Correct 9 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14368 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14308 KB Output is correct
13 Correct 10 ms 14392 KB Output is correct
14 Correct 8 ms 14280 KB Output is correct
15 Correct 8 ms 14400 KB Output is correct
16 Correct 9 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
20 Correct 8 ms 14408 KB Output is correct
21 Correct 10 ms 14412 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 12 ms 14500 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 13 ms 14416 KB Output is correct
27 Correct 12 ms 14440 KB Output is correct
28 Correct 9 ms 14456 KB Output is correct
29 Correct 11 ms 14416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14368 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14308 KB Output is correct
13 Correct 10 ms 14392 KB Output is correct
14 Correct 8 ms 14280 KB Output is correct
15 Correct 8 ms 14400 KB Output is correct
16 Correct 9 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
20 Correct 8 ms 14408 KB Output is correct
21 Correct 10 ms 14412 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 12 ms 14500 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 13 ms 14416 KB Output is correct
27 Correct 12 ms 14440 KB Output is correct
28 Correct 9 ms 14456 KB Output is correct
29 Correct 11 ms 14416 KB Output is correct
30 Correct 23 ms 15760 KB Output is correct
31 Correct 12 ms 15056 KB Output is correct
32 Correct 29 ms 16844 KB Output is correct
33 Correct 33 ms 16428 KB Output is correct
34 Correct 1408 ms 18888 KB Output is correct
35 Correct 387 ms 17320 KB Output is correct
36 Correct 57 ms 16388 KB Output is correct
37 Correct 53 ms 16400 KB Output is correct
38 Correct 33 ms 16188 KB Output is correct
39 Correct 36 ms 16228 KB Output is correct
40 Correct 1014 ms 18860 KB Output is correct
41 Correct 179 ms 16892 KB Output is correct
42 Correct 129 ms 16640 KB Output is correct
43 Correct 45 ms 17788 KB Output is correct
44 Correct 997 ms 18896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14288 KB Output is correct
2 Correct 9 ms 14368 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 8 ms 14308 KB Output is correct
13 Correct 10 ms 14392 KB Output is correct
14 Correct 8 ms 14280 KB Output is correct
15 Correct 8 ms 14400 KB Output is correct
16 Correct 9 ms 14400 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 8 ms 14288 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
20 Correct 8 ms 14408 KB Output is correct
21 Correct 10 ms 14412 KB Output is correct
22 Correct 8 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 12 ms 14500 KB Output is correct
25 Correct 10 ms 14416 KB Output is correct
26 Correct 13 ms 14416 KB Output is correct
27 Correct 12 ms 14440 KB Output is correct
28 Correct 9 ms 14456 KB Output is correct
29 Correct 11 ms 14416 KB Output is correct
30 Correct 23 ms 15760 KB Output is correct
31 Correct 12 ms 15056 KB Output is correct
32 Correct 29 ms 16844 KB Output is correct
33 Correct 33 ms 16428 KB Output is correct
34 Correct 1408 ms 18888 KB Output is correct
35 Correct 387 ms 17320 KB Output is correct
36 Correct 57 ms 16388 KB Output is correct
37 Correct 53 ms 16400 KB Output is correct
38 Correct 33 ms 16188 KB Output is correct
39 Correct 36 ms 16228 KB Output is correct
40 Correct 1014 ms 18860 KB Output is correct
41 Correct 179 ms 16892 KB Output is correct
42 Correct 129 ms 16640 KB Output is correct
43 Correct 45 ms 17788 KB Output is correct
44 Correct 997 ms 18896 KB Output is correct
45 Correct 265 ms 28040 KB Output is correct
46 Correct 19 ms 17192 KB Output is correct
47 Correct 15 ms 17096 KB Output is correct
48 Correct 336 ms 45600 KB Output is correct
49 Correct 280 ms 35496 KB Output is correct
50 Execution timed out 4054 ms 47176 KB Time limit exceeded
51 Halted 0 ms 0 KB -