Submission #816357

# Submission time Handle Problem Language Result Execution time Memory
816357 2023-08-09T04:53:59 Z 이동현(#10127) Game (APIO22_game) C++17
30 / 100
4000 ms 3964 KB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

int n, k;
int chk[30004];
vector<int> way[30004], wayb[30004];
int que[30004], f, r;

void init(int N, int K) {
    n = N, k = K;
    assert(n <= 30000 && k <= 1000);
}

int add_teleporter(int u, int v) {
    way[u].push_back(v);
    wayb[v].push_back(u);
    int mn = (int)1e9, mx = -1;
    memset(chk, 0, sizeof(chk));
    f = r = 0;
    que[r++] = v, chk[v] = 1;
    while(f < r){
        int now = que[f++];
        if(now < k) mn = min(mn, now);

        for(auto&nxt:way[now]){
            if(!chk[nxt]){
                chk[nxt] = 1;
                que[r++] = nxt;
            }
        }
    }

    memset(chk, 0, sizeof(chk));
    f = r = 0;
    que[r++] = u, chk[u] = 1;
    while(f < r){
        int now = que[f++];
        if(now < k) mx = max(mx, now);

        for(auto&nxt:wayb[now]){
            if(!chk[nxt]){
                chk[nxt] = 1;
                que[r++] = nxt;
            }
        }
    }

    return mn <= mx;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1744 KB Output is correct
3 Correct 2 ms 1744 KB Output is correct
4 Correct 1 ms 1744 KB Output is correct
5 Correct 2 ms 1744 KB Output is correct
6 Correct 2 ms 1744 KB Output is correct
7 Correct 2 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1744 KB Output is correct
3 Correct 2 ms 1744 KB Output is correct
4 Correct 1 ms 1744 KB Output is correct
5 Correct 2 ms 1744 KB Output is correct
6 Correct 2 ms 1744 KB Output is correct
7 Correct 2 ms 1744 KB Output is correct
8 Correct 1 ms 1744 KB Output is correct
9 Correct 1 ms 1852 KB Output is correct
10 Correct 1 ms 1772 KB Output is correct
11 Correct 1 ms 1744 KB Output is correct
12 Correct 1 ms 1744 KB Output is correct
13 Correct 1 ms 1744 KB Output is correct
14 Correct 1 ms 1744 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 2 ms 1744 KB Output is correct
18 Correct 1 ms 1744 KB Output is correct
19 Correct 1 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1744 KB Output is correct
3 Correct 2 ms 1744 KB Output is correct
4 Correct 1 ms 1744 KB Output is correct
5 Correct 2 ms 1744 KB Output is correct
6 Correct 2 ms 1744 KB Output is correct
7 Correct 2 ms 1744 KB Output is correct
8 Correct 1 ms 1744 KB Output is correct
9 Correct 1 ms 1852 KB Output is correct
10 Correct 1 ms 1772 KB Output is correct
11 Correct 1 ms 1744 KB Output is correct
12 Correct 1 ms 1744 KB Output is correct
13 Correct 1 ms 1744 KB Output is correct
14 Correct 1 ms 1744 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 2 ms 1744 KB Output is correct
18 Correct 1 ms 1744 KB Output is correct
19 Correct 1 ms 1744 KB Output is correct
20 Correct 4 ms 1744 KB Output is correct
21 Correct 1 ms 1744 KB Output is correct
22 Correct 4 ms 1872 KB Output is correct
23 Correct 4 ms 1836 KB Output is correct
24 Correct 7 ms 1908 KB Output is correct
25 Correct 18 ms 1888 KB Output is correct
26 Correct 34 ms 1908 KB Output is correct
27 Correct 13 ms 1872 KB Output is correct
28 Correct 8 ms 1832 KB Output is correct
29 Correct 13 ms 1888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1744 KB Output is correct
3 Correct 2 ms 1744 KB Output is correct
4 Correct 1 ms 1744 KB Output is correct
5 Correct 2 ms 1744 KB Output is correct
6 Correct 2 ms 1744 KB Output is correct
7 Correct 2 ms 1744 KB Output is correct
8 Correct 1 ms 1744 KB Output is correct
9 Correct 1 ms 1852 KB Output is correct
10 Correct 1 ms 1772 KB Output is correct
11 Correct 1 ms 1744 KB Output is correct
12 Correct 1 ms 1744 KB Output is correct
13 Correct 1 ms 1744 KB Output is correct
14 Correct 1 ms 1744 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 2 ms 1744 KB Output is correct
18 Correct 1 ms 1744 KB Output is correct
19 Correct 1 ms 1744 KB Output is correct
20 Correct 4 ms 1744 KB Output is correct
21 Correct 1 ms 1744 KB Output is correct
22 Correct 4 ms 1872 KB Output is correct
23 Correct 4 ms 1836 KB Output is correct
24 Correct 7 ms 1908 KB Output is correct
25 Correct 18 ms 1888 KB Output is correct
26 Correct 34 ms 1908 KB Output is correct
27 Correct 13 ms 1872 KB Output is correct
28 Correct 8 ms 1832 KB Output is correct
29 Correct 13 ms 1888 KB Output is correct
30 Correct 93 ms 2876 KB Output is correct
31 Correct 22 ms 2184 KB Output is correct
32 Correct 106 ms 3628 KB Output is correct
33 Correct 98 ms 3612 KB Output is correct
34 Correct 1000 ms 3772 KB Output is correct
35 Correct 836 ms 3840 KB Output is correct
36 Correct 953 ms 3788 KB Output is correct
37 Correct 563 ms 3752 KB Output is correct
38 Correct 560 ms 3528 KB Output is correct
39 Correct 625 ms 3576 KB Output is correct
40 Correct 976 ms 3964 KB Output is correct
41 Correct 605 ms 3520 KB Output is correct
42 Correct 355 ms 3472 KB Output is correct
43 Execution timed out 4102 ms 3892 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1744 KB Output is correct
2 Correct 1 ms 1744 KB Output is correct
3 Correct 2 ms 1744 KB Output is correct
4 Correct 1 ms 1744 KB Output is correct
5 Correct 2 ms 1744 KB Output is correct
6 Correct 2 ms 1744 KB Output is correct
7 Correct 2 ms 1744 KB Output is correct
8 Correct 1 ms 1744 KB Output is correct
9 Correct 1 ms 1852 KB Output is correct
10 Correct 1 ms 1772 KB Output is correct
11 Correct 1 ms 1744 KB Output is correct
12 Correct 1 ms 1744 KB Output is correct
13 Correct 1 ms 1744 KB Output is correct
14 Correct 1 ms 1744 KB Output is correct
15 Correct 2 ms 1744 KB Output is correct
16 Correct 2 ms 1744 KB Output is correct
17 Correct 2 ms 1744 KB Output is correct
18 Correct 1 ms 1744 KB Output is correct
19 Correct 1 ms 1744 KB Output is correct
20 Correct 4 ms 1744 KB Output is correct
21 Correct 1 ms 1744 KB Output is correct
22 Correct 4 ms 1872 KB Output is correct
23 Correct 4 ms 1836 KB Output is correct
24 Correct 7 ms 1908 KB Output is correct
25 Correct 18 ms 1888 KB Output is correct
26 Correct 34 ms 1908 KB Output is correct
27 Correct 13 ms 1872 KB Output is correct
28 Correct 8 ms 1832 KB Output is correct
29 Correct 13 ms 1888 KB Output is correct
30 Correct 93 ms 2876 KB Output is correct
31 Correct 22 ms 2184 KB Output is correct
32 Correct 106 ms 3628 KB Output is correct
33 Correct 98 ms 3612 KB Output is correct
34 Correct 1000 ms 3772 KB Output is correct
35 Correct 836 ms 3840 KB Output is correct
36 Correct 953 ms 3788 KB Output is correct
37 Correct 563 ms 3752 KB Output is correct
38 Correct 560 ms 3528 KB Output is correct
39 Correct 625 ms 3576 KB Output is correct
40 Correct 976 ms 3964 KB Output is correct
41 Correct 605 ms 3520 KB Output is correct
42 Correct 355 ms 3472 KB Output is correct
43 Execution timed out 4102 ms 3892 KB Time limit exceeded
44 Halted 0 ms 0 KB -