Submission #640415

# Submission time Handle Problem Language Result Execution time Memory
640415 2022-09-14T15:16:02 Z qwerasdfzxcl Game (APIO22_game) C++17
60 / 100
380 ms 62436 KB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
vector<int> adj[600600], INV[600600];
int n, k, cyc;
ll a[600600]; ///1 -> left, 2 -> right, 3 -> cycle (bit string)

void add_edge(int x, int y, int first = 1){
    if (first) {adj[x].push_back(y); INV[y].push_back(x);}
    if (cyc) return;

    int l = 1, r = k;
    ll prvx = a[x], prvy = a[y];

    for (int i=0;;i+=2){
        if (l>r) break;
        int m = (l+r)>>1;
        a[x] |= (ll)((x==m)?1:((x==m+n)?2:0))<<i;
        a[y] |= (ll)((y==m)?1:((y==m+n)?2:0))<<i;

        int X = (a[x]&(3LL<<i))>>i, Y = (a[y]&(3LL<<i))>>i;
        Y |= X&2;
        X |= Y&1;

        if (X==3 || Y==3) {cyc = 1; break;}
        if (X!=Y) break;

        a[x] |= X<<i, a[y] |= Y<<i;
        if (X&1) r = m-1;
        else if (X&2) l = m+1;
        else break;
    }

    if (prvx!=a[x]) for (auto &nx:INV[x]) add_edge(nx, x, 0);
    if (prvy!=a[y]) for (auto &ny:adj[y]) add_edge(y, ny, 0);
}

void init(int N, int K) {
    n = N, k = K;

    for (int i=1;i<k;i++){
        add_edge(i, i+n);
        add_edge(i+n, i+1);
    }
    add_edge(k, k+n);
}

int add_teleporter(int u, int v) {
    ++u, ++v;
    add_edge(u<=k?u+n:u, v);
    return cyc;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 28496 KB Output is correct
2 Correct 14 ms 28496 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 18 ms 28412 KB Output is correct
5 Correct 16 ms 28496 KB Output is correct
6 Correct 15 ms 28496 KB Output is correct
7 Correct 16 ms 28496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 28496 KB Output is correct
2 Correct 14 ms 28496 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 18 ms 28412 KB Output is correct
5 Correct 16 ms 28496 KB Output is correct
6 Correct 15 ms 28496 KB Output is correct
7 Correct 16 ms 28496 KB Output is correct
8 Correct 14 ms 28496 KB Output is correct
9 Correct 15 ms 28496 KB Output is correct
10 Correct 14 ms 28496 KB Output is correct
11 Correct 15 ms 28496 KB Output is correct
12 Correct 14 ms 28496 KB Output is correct
13 Correct 15 ms 28496 KB Output is correct
14 Correct 14 ms 28496 KB Output is correct
15 Correct 17 ms 28496 KB Output is correct
16 Correct 15 ms 28516 KB Output is correct
17 Correct 16 ms 28516 KB Output is correct
18 Correct 17 ms 28500 KB Output is correct
19 Correct 14 ms 28528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 28496 KB Output is correct
2 Correct 14 ms 28496 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 18 ms 28412 KB Output is correct
5 Correct 16 ms 28496 KB Output is correct
6 Correct 15 ms 28496 KB Output is correct
7 Correct 16 ms 28496 KB Output is correct
8 Correct 14 ms 28496 KB Output is correct
9 Correct 15 ms 28496 KB Output is correct
10 Correct 14 ms 28496 KB Output is correct
11 Correct 15 ms 28496 KB Output is correct
12 Correct 14 ms 28496 KB Output is correct
13 Correct 15 ms 28496 KB Output is correct
14 Correct 14 ms 28496 KB Output is correct
15 Correct 17 ms 28496 KB Output is correct
16 Correct 15 ms 28516 KB Output is correct
17 Correct 16 ms 28516 KB Output is correct
18 Correct 17 ms 28500 KB Output is correct
19 Correct 14 ms 28528 KB Output is correct
20 Correct 15 ms 28496 KB Output is correct
21 Correct 17 ms 28448 KB Output is correct
22 Correct 14 ms 28496 KB Output is correct
23 Correct 15 ms 28496 KB Output is correct
24 Correct 15 ms 28600 KB Output is correct
25 Correct 17 ms 28624 KB Output is correct
26 Correct 19 ms 28552 KB Output is correct
27 Correct 19 ms 28612 KB Output is correct
28 Correct 20 ms 28736 KB Output is correct
29 Correct 18 ms 28672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 28496 KB Output is correct
2 Correct 14 ms 28496 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 18 ms 28412 KB Output is correct
5 Correct 16 ms 28496 KB Output is correct
6 Correct 15 ms 28496 KB Output is correct
7 Correct 16 ms 28496 KB Output is correct
8 Correct 14 ms 28496 KB Output is correct
9 Correct 15 ms 28496 KB Output is correct
10 Correct 14 ms 28496 KB Output is correct
11 Correct 15 ms 28496 KB Output is correct
12 Correct 14 ms 28496 KB Output is correct
13 Correct 15 ms 28496 KB Output is correct
14 Correct 14 ms 28496 KB Output is correct
15 Correct 17 ms 28496 KB Output is correct
16 Correct 15 ms 28516 KB Output is correct
17 Correct 16 ms 28516 KB Output is correct
18 Correct 17 ms 28500 KB Output is correct
19 Correct 14 ms 28528 KB Output is correct
20 Correct 15 ms 28496 KB Output is correct
21 Correct 17 ms 28448 KB Output is correct
22 Correct 14 ms 28496 KB Output is correct
23 Correct 15 ms 28496 KB Output is correct
24 Correct 15 ms 28600 KB Output is correct
25 Correct 17 ms 28624 KB Output is correct
26 Correct 19 ms 28552 KB Output is correct
27 Correct 19 ms 28612 KB Output is correct
28 Correct 20 ms 28736 KB Output is correct
29 Correct 18 ms 28672 KB Output is correct
30 Correct 32 ms 29848 KB Output is correct
31 Correct 23 ms 29404 KB Output is correct
32 Correct 36 ms 31948 KB Output is correct
33 Correct 40 ms 30568 KB Output is correct
34 Correct 64 ms 36040 KB Output is correct
35 Correct 89 ms 32512 KB Output is correct
36 Correct 73 ms 30664 KB Output is correct
37 Correct 50 ms 30744 KB Output is correct
38 Correct 45 ms 30584 KB Output is correct
39 Correct 53 ms 30536 KB Output is correct
40 Correct 75 ms 35780 KB Output is correct
41 Correct 82 ms 33412 KB Output is correct
42 Correct 48 ms 31300 KB Output is correct
43 Correct 68 ms 32168 KB Output is correct
44 Correct 78 ms 32712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 28496 KB Output is correct
2 Correct 14 ms 28496 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 18 ms 28412 KB Output is correct
5 Correct 16 ms 28496 KB Output is correct
6 Correct 15 ms 28496 KB Output is correct
7 Correct 16 ms 28496 KB Output is correct
8 Correct 14 ms 28496 KB Output is correct
9 Correct 15 ms 28496 KB Output is correct
10 Correct 14 ms 28496 KB Output is correct
11 Correct 15 ms 28496 KB Output is correct
12 Correct 14 ms 28496 KB Output is correct
13 Correct 15 ms 28496 KB Output is correct
14 Correct 14 ms 28496 KB Output is correct
15 Correct 17 ms 28496 KB Output is correct
16 Correct 15 ms 28516 KB Output is correct
17 Correct 16 ms 28516 KB Output is correct
18 Correct 17 ms 28500 KB Output is correct
19 Correct 14 ms 28528 KB Output is correct
20 Correct 15 ms 28496 KB Output is correct
21 Correct 17 ms 28448 KB Output is correct
22 Correct 14 ms 28496 KB Output is correct
23 Correct 15 ms 28496 KB Output is correct
24 Correct 15 ms 28600 KB Output is correct
25 Correct 17 ms 28624 KB Output is correct
26 Correct 19 ms 28552 KB Output is correct
27 Correct 19 ms 28612 KB Output is correct
28 Correct 20 ms 28736 KB Output is correct
29 Correct 18 ms 28672 KB Output is correct
30 Correct 32 ms 29848 KB Output is correct
31 Correct 23 ms 29404 KB Output is correct
32 Correct 36 ms 31948 KB Output is correct
33 Correct 40 ms 30568 KB Output is correct
34 Correct 64 ms 36040 KB Output is correct
35 Correct 89 ms 32512 KB Output is correct
36 Correct 73 ms 30664 KB Output is correct
37 Correct 50 ms 30744 KB Output is correct
38 Correct 45 ms 30584 KB Output is correct
39 Correct 53 ms 30536 KB Output is correct
40 Correct 75 ms 35780 KB Output is correct
41 Correct 82 ms 33412 KB Output is correct
42 Correct 48 ms 31300 KB Output is correct
43 Correct 68 ms 32168 KB Output is correct
44 Correct 78 ms 32712 KB Output is correct
45 Correct 269 ms 42268 KB Output is correct
46 Correct 21 ms 31568 KB Output is correct
47 Correct 23 ms 31720 KB Output is correct
48 Correct 380 ms 61748 KB Output is correct
49 Correct 280 ms 49796 KB Output is correct
50 Incorrect 68 ms 62436 KB Wrong Answer[1]
51 Halted 0 ms 0 KB -