Submission #741903

# Submission time Handle Problem Language Result Execution time Memory
741903 2023-05-15T04:27:45 Z t6twotwo Game (APIO22_game) C++17
60 / 100
4000 ms 180000 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<vector<bool>> a, b;
vector<vector<int>> adj, jda;
void init(int n, int k) {
    N = n;
    K = k;
    adj.resize(N);
    jda.resize(N);
    a = vector(N, vector<bool>(K));
    b = vector(K, vector<bool>(N));
    for (int i = 0; i + 1 < K; i++) {
        adj[i].push_back(i + 1);
        jda[i + 1].push_back(i);
        for (int j = i + 1; j < K; j++) {
            a[i][j] = 1;
            b[i][j] = 1;
        }
    }
}
int add_teleporter(int u, int v) {
    if (u < K && v < K) {
        return v <= u;
    }
    adj[u].push_back(v);
    jda[v].push_back(u);
    for (int i = 0; i < K; i++) {
        if (b[i][u] || i == u) {
            b[i][v] = 1;
            queue<int> q;
            q.push(v);
            while (!q.empty()) {
                int x = q.front();
                q.pop();
                for (int y : adj[x]) {
                    if (!b[i][y]) {
                        b[i][y] = 1;
                        q.push(y);
                    }
                }
            }
        }
    }
    for (int i = 0; i < K; i++) {
        if (a[v][i] || i == v) {
            a[u][i] = 1;
            queue<int> q;
            q.push(u);
            while (!q.empty()) {
                int x = q.front();
                q.pop();
                for (int y : jda[x]) {
                    if (!a[y][i]) {
                        a[y][i] = 1;
                        q.push(y);
                    }
                }
            }
        }
    }
    bool flag = 0;
    for (int i = 0; i < K; i++) {
        if (a[u][i]) {
            flag = 1;
        }
        if (flag && b[i][u]) {
            return 1;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 3 ms 464 KB Output is correct
23 Correct 1 ms 436 KB Output is correct
24 Correct 15 ms 592 KB Output is correct
25 Correct 45 ms 556 KB Output is correct
26 Correct 17 ms 464 KB Output is correct
27 Correct 68 ms 604 KB Output is correct
28 Correct 39 ms 600 KB Output is correct
29 Correct 49 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 3 ms 464 KB Output is correct
23 Correct 1 ms 436 KB Output is correct
24 Correct 15 ms 592 KB Output is correct
25 Correct 45 ms 556 KB Output is correct
26 Correct 17 ms 464 KB Output is correct
27 Correct 68 ms 604 KB Output is correct
28 Correct 39 ms 600 KB Output is correct
29 Correct 49 ms 592 KB Output is correct
30 Correct 50 ms 5276 KB Output is correct
31 Correct 83 ms 11204 KB Output is correct
32 Correct 146 ms 5972 KB Output is correct
33 Correct 23 ms 5608 KB Output is correct
34 Correct 2008 ms 12816 KB Output is correct
35 Correct 1709 ms 12888 KB Output is correct
36 Correct 157 ms 6112 KB Output is correct
37 Correct 2195 ms 12684 KB Output is correct
38 Correct 1316 ms 12612 KB Output is correct
39 Correct 1365 ms 12572 KB Output is correct
40 Correct 2351 ms 12992 KB Output is correct
41 Correct 1685 ms 12660 KB Output is correct
42 Correct 1206 ms 12528 KB Output is correct
43 Correct 3809 ms 12972 KB Output is correct
44 Correct 2343 ms 12744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 3 ms 464 KB Output is correct
23 Correct 1 ms 436 KB Output is correct
24 Correct 15 ms 592 KB Output is correct
25 Correct 45 ms 556 KB Output is correct
26 Correct 17 ms 464 KB Output is correct
27 Correct 68 ms 604 KB Output is correct
28 Correct 39 ms 600 KB Output is correct
29 Correct 49 ms 592 KB Output is correct
30 Correct 50 ms 5276 KB Output is correct
31 Correct 83 ms 11204 KB Output is correct
32 Correct 146 ms 5972 KB Output is correct
33 Correct 23 ms 5608 KB Output is correct
34 Correct 2008 ms 12816 KB Output is correct
35 Correct 1709 ms 12888 KB Output is correct
36 Correct 157 ms 6112 KB Output is correct
37 Correct 2195 ms 12684 KB Output is correct
38 Correct 1316 ms 12612 KB Output is correct
39 Correct 1365 ms 12572 KB Output is correct
40 Correct 2351 ms 12992 KB Output is correct
41 Correct 1685 ms 12660 KB Output is correct
42 Correct 1206 ms 12528 KB Output is correct
43 Correct 3809 ms 12972 KB Output is correct
44 Correct 2343 ms 12744 KB Output is correct
45 Correct 686 ms 50484 KB Output is correct
46 Correct 234 ms 105644 KB Output is correct
47 Correct 360 ms 180000 KB Output is correct
48 Execution timed out 4056 ms 58080 KB Time limit exceeded
49 Halted 0 ms 0 KB -