답안 #640413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640413 2022-09-14T15:09:26 Z qwerasdfzxcl 게임 (APIO22_game) C++17
100 / 100
1748 ms 96640 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;
        assert(i<=40);

        int m = (l+r)>>1;
        if (x==m) a[x] |= 1LL<<i;
        if (x==m+n) a[x] |= 2LL<<i;
        if (y==m) a[x] |= 1LL<<i;
        if (y==m+n) a[y] |= 2LL<<i;

        if (a[x]&(2LL<<i)) a[y] |= 2LL<<i;
        if (a[y]&(1LL<<i)) a[x] |= 1LL<<i;

        if ((a[x]&(3LL<<i)) == (3LL<<i)) cyc = 1;
        if ((a[y]&(3LL<<i)) == (3LL<<i)) cyc = 1;
        if (cyc) break;
        if ((a[x]&(3LL<<i)) != (a[y]&(3LL<<i))) break;

        if (a[x]&(1LL<<i)) r = m-1;
        else l = m+1;
    }

    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 28496 KB Output is correct
2 Correct 13 ms 28412 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 13 ms 28504 KB Output is correct
5 Correct 14 ms 28452 KB Output is correct
6 Correct 14 ms 28508 KB Output is correct
7 Correct 14 ms 28512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 28496 KB Output is correct
2 Correct 13 ms 28412 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 13 ms 28504 KB Output is correct
5 Correct 14 ms 28452 KB Output is correct
6 Correct 14 ms 28508 KB Output is correct
7 Correct 14 ms 28512 KB Output is correct
8 Correct 13 ms 28396 KB Output is correct
9 Correct 14 ms 28432 KB Output is correct
10 Correct 14 ms 28396 KB Output is correct
11 Correct 15 ms 28408 KB Output is correct
12 Correct 15 ms 28396 KB Output is correct
13 Correct 14 ms 28496 KB Output is correct
14 Correct 16 ms 28496 KB Output is correct
15 Correct 14 ms 28524 KB Output is correct
16 Correct 14 ms 28472 KB Output is correct
17 Correct 14 ms 28496 KB Output is correct
18 Correct 14 ms 28480 KB Output is correct
19 Correct 13 ms 28496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 28496 KB Output is correct
2 Correct 13 ms 28412 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 13 ms 28504 KB Output is correct
5 Correct 14 ms 28452 KB Output is correct
6 Correct 14 ms 28508 KB Output is correct
7 Correct 14 ms 28512 KB Output is correct
8 Correct 13 ms 28396 KB Output is correct
9 Correct 14 ms 28432 KB Output is correct
10 Correct 14 ms 28396 KB Output is correct
11 Correct 15 ms 28408 KB Output is correct
12 Correct 15 ms 28396 KB Output is correct
13 Correct 14 ms 28496 KB Output is correct
14 Correct 16 ms 28496 KB Output is correct
15 Correct 14 ms 28524 KB Output is correct
16 Correct 14 ms 28472 KB Output is correct
17 Correct 14 ms 28496 KB Output is correct
18 Correct 14 ms 28480 KB Output is correct
19 Correct 13 ms 28496 KB Output is correct
20 Correct 15 ms 28632 KB Output is correct
21 Correct 14 ms 28544 KB Output is correct
22 Correct 15 ms 28536 KB Output is correct
23 Correct 14 ms 28516 KB Output is correct
24 Correct 15 ms 28624 KB Output is correct
25 Correct 17 ms 28624 KB Output is correct
26 Correct 16 ms 28544 KB Output is correct
27 Correct 16 ms 28624 KB Output is correct
28 Correct 15 ms 28724 KB Output is correct
29 Correct 16 ms 28760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 28496 KB Output is correct
2 Correct 13 ms 28412 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 13 ms 28504 KB Output is correct
5 Correct 14 ms 28452 KB Output is correct
6 Correct 14 ms 28508 KB Output is correct
7 Correct 14 ms 28512 KB Output is correct
8 Correct 13 ms 28396 KB Output is correct
9 Correct 14 ms 28432 KB Output is correct
10 Correct 14 ms 28396 KB Output is correct
11 Correct 15 ms 28408 KB Output is correct
12 Correct 15 ms 28396 KB Output is correct
13 Correct 14 ms 28496 KB Output is correct
14 Correct 16 ms 28496 KB Output is correct
15 Correct 14 ms 28524 KB Output is correct
16 Correct 14 ms 28472 KB Output is correct
17 Correct 14 ms 28496 KB Output is correct
18 Correct 14 ms 28480 KB Output is correct
19 Correct 13 ms 28496 KB Output is correct
20 Correct 15 ms 28632 KB Output is correct
21 Correct 14 ms 28544 KB Output is correct
22 Correct 15 ms 28536 KB Output is correct
23 Correct 14 ms 28516 KB Output is correct
24 Correct 15 ms 28624 KB Output is correct
25 Correct 17 ms 28624 KB Output is correct
26 Correct 16 ms 28544 KB Output is correct
27 Correct 16 ms 28624 KB Output is correct
28 Correct 15 ms 28724 KB Output is correct
29 Correct 16 ms 28760 KB Output is correct
30 Correct 34 ms 29904 KB Output is correct
31 Correct 19 ms 29264 KB Output is correct
32 Correct 33 ms 31876 KB Output is correct
33 Correct 31 ms 30596 KB Output is correct
34 Correct 65 ms 36100 KB Output is correct
35 Correct 62 ms 32464 KB Output is correct
36 Correct 56 ms 30580 KB Output is correct
37 Correct 53 ms 30756 KB Output is correct
38 Correct 42 ms 30480 KB Output is correct
39 Correct 57 ms 30536 KB Output is correct
40 Correct 68 ms 35724 KB Output is correct
41 Correct 59 ms 33400 KB Output is correct
42 Correct 49 ms 31276 KB Output is correct
43 Correct 70 ms 32176 KB Output is correct
44 Correct 70 ms 32752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 28496 KB Output is correct
2 Correct 13 ms 28412 KB Output is correct
3 Correct 15 ms 28496 KB Output is correct
4 Correct 13 ms 28504 KB Output is correct
5 Correct 14 ms 28452 KB Output is correct
6 Correct 14 ms 28508 KB Output is correct
7 Correct 14 ms 28512 KB Output is correct
8 Correct 13 ms 28396 KB Output is correct
9 Correct 14 ms 28432 KB Output is correct
10 Correct 14 ms 28396 KB Output is correct
11 Correct 15 ms 28408 KB Output is correct
12 Correct 15 ms 28396 KB Output is correct
13 Correct 14 ms 28496 KB Output is correct
14 Correct 16 ms 28496 KB Output is correct
15 Correct 14 ms 28524 KB Output is correct
16 Correct 14 ms 28472 KB Output is correct
17 Correct 14 ms 28496 KB Output is correct
18 Correct 14 ms 28480 KB Output is correct
19 Correct 13 ms 28496 KB Output is correct
20 Correct 15 ms 28632 KB Output is correct
21 Correct 14 ms 28544 KB Output is correct
22 Correct 15 ms 28536 KB Output is correct
23 Correct 14 ms 28516 KB Output is correct
24 Correct 15 ms 28624 KB Output is correct
25 Correct 17 ms 28624 KB Output is correct
26 Correct 16 ms 28544 KB Output is correct
27 Correct 16 ms 28624 KB Output is correct
28 Correct 15 ms 28724 KB Output is correct
29 Correct 16 ms 28760 KB Output is correct
30 Correct 34 ms 29904 KB Output is correct
31 Correct 19 ms 29264 KB Output is correct
32 Correct 33 ms 31876 KB Output is correct
33 Correct 31 ms 30596 KB Output is correct
34 Correct 65 ms 36100 KB Output is correct
35 Correct 62 ms 32464 KB Output is correct
36 Correct 56 ms 30580 KB Output is correct
37 Correct 53 ms 30756 KB Output is correct
38 Correct 42 ms 30480 KB Output is correct
39 Correct 57 ms 30536 KB Output is correct
40 Correct 68 ms 35724 KB Output is correct
41 Correct 59 ms 33400 KB Output is correct
42 Correct 49 ms 31276 KB Output is correct
43 Correct 70 ms 32176 KB Output is correct
44 Correct 70 ms 32752 KB Output is correct
45 Correct 230 ms 41664 KB Output is correct
46 Correct 24 ms 29264 KB Output is correct
47 Correct 21 ms 29392 KB Output is correct
48 Correct 349 ms 61632 KB Output is correct
49 Correct 271 ms 49652 KB Output is correct
50 Correct 1093 ms 89312 KB Output is correct
51 Correct 1128 ms 69832 KB Output is correct
52 Correct 610 ms 49588 KB Output is correct
53 Correct 855 ms 50012 KB Output is correct
54 Correct 999 ms 51476 KB Output is correct
55 Correct 1221 ms 50636 KB Output is correct
56 Correct 1577 ms 51432 KB Output is correct
57 Correct 726 ms 74448 KB Output is correct
58 Correct 675 ms 74652 KB Output is correct
59 Correct 752 ms 74792 KB Output is correct
60 Correct 749 ms 74744 KB Output is correct
61 Correct 875 ms 74508 KB Output is correct
62 Correct 709 ms 66124 KB Output is correct
63 Correct 626 ms 62920 KB Output is correct
64 Correct 1555 ms 96640 KB Output is correct
65 Correct 649 ms 56020 KB Output is correct
66 Correct 568 ms 52216 KB Output is correct
67 Correct 1024 ms 62544 KB Output is correct
68 Correct 261 ms 51656 KB Output is correct
69 Correct 113 ms 45804 KB Output is correct
70 Correct 1063 ms 69796 KB Output is correct
71 Correct 378 ms 52448 KB Output is correct
72 Correct 303 ms 48728 KB Output is correct
73 Correct 871 ms 69348 KB Output is correct
74 Correct 1748 ms 53300 KB Output is correct
75 Correct 1551 ms 65600 KB Output is correct
76 Correct 1727 ms 73280 KB Output is correct