Submission #816271

# Submission time Handle Problem Language Result Execution time Memory
816271 2023-08-09T04:38:33 Z 반딧불(#10124) Game (APIO22_game) C++17
30 / 100
1167 ms 262144 KB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

int n, k;
vector<int> link[30002];
int tosee[1002][30002];
bool visited[1002][30002];
int newTime[1002][30002];
int Q;

void init(int N, int K){
    n = N, k = K;
    for(int i=0; i<k; i++){
        if(i+1<k) link[i].push_back(i+1);
        for(int j=i; j<k; j++) visited[i][j] = 1;
    }
}

bool bfs(int st, int x){
    queue<int> que;
    que.push(x);
    while(!que.empty()){
        int x = que.front(); que.pop();
        visited[st][x] = 1;
        while(tosee[st][x] < (int)link[x].size()){
            int y = link[x][tosee[st][x]++];
            visited[st][y] = 1;
            if(y==st) return true;
            if(tosee[st][y] == (int)link[y].size() || newTime[st][y] == Q) continue;
            newTime[st][y] = Q;
            que.push(y);
        }
    }
    return false;
}

int add_teleporter(int u, int v){
    Q++;
    link[u].push_back(v);
    for(int i=0; i<k; i++){
        if(visited[i][u]) if(bfs(i, u)) return true;
    }
    return false;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 2256 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 3 ms 2204 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 2256 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 3 ms 2204 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2256 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 2 ms 1488 KB Output is correct
15 Correct 2 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 2256 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 3 ms 2204 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2256 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 2 ms 1488 KB Output is correct
15 Correct 2 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 2 ms 1180 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 2 ms 2328 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 10 ms 7116 KB Output is correct
25 Correct 19 ms 6044 KB Output is correct
26 Correct 18 ms 3024 KB Output is correct
27 Correct 90 ms 10568 KB Output is correct
28 Correct 25 ms 10004 KB Output is correct
29 Correct 44 ms 10028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 2256 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 3 ms 2204 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2256 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 2 ms 1488 KB Output is correct
15 Correct 2 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 2 ms 1180 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 2 ms 2328 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 10 ms 7116 KB Output is correct
25 Correct 19 ms 6044 KB Output is correct
26 Correct 18 ms 3024 KB Output is correct
27 Correct 90 ms 10568 KB Output is correct
28 Correct 25 ms 10004 KB Output is correct
29 Correct 44 ms 10028 KB Output is correct
30 Correct 47 ms 25880 KB Output is correct
31 Correct 216 ms 133540 KB Output is correct
32 Correct 35 ms 8040 KB Output is correct
33 Correct 12 ms 4080 KB Output is correct
34 Correct 793 ms 137940 KB Output is correct
35 Runtime error 1167 ms 262144 KB Execution killed with signal 9
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 976 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 2256 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 3 ms 2204 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2256 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 1104 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 1 ms 1104 KB Output is correct
14 Correct 2 ms 1488 KB Output is correct
15 Correct 2 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 2 ms 1180 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 2 ms 2328 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 10 ms 7116 KB Output is correct
25 Correct 19 ms 6044 KB Output is correct
26 Correct 18 ms 3024 KB Output is correct
27 Correct 90 ms 10568 KB Output is correct
28 Correct 25 ms 10004 KB Output is correct
29 Correct 44 ms 10028 KB Output is correct
30 Correct 47 ms 25880 KB Output is correct
31 Correct 216 ms 133540 KB Output is correct
32 Correct 35 ms 8040 KB Output is correct
33 Correct 12 ms 4080 KB Output is correct
34 Correct 793 ms 137940 KB Output is correct
35 Runtime error 1167 ms 262144 KB Execution killed with signal 9
36 Halted 0 ms 0 KB -