Submission #816279

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

using namespace std;

int n, k;
vector<int> link[30002];
short tosee[1002][30002];
bool visited[1002][30002];
short 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 2128 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 2 ms 2128 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2128 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 2128 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 2 ms 2128 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2128 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 1 ms 1360 KB Output is correct
15 Correct 1 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1644 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 2128 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 2 ms 2128 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2128 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 1 ms 1360 KB Output is correct
15 Correct 1 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1644 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 1 ms 1104 KB Output is correct
21 Correct 1 ms 2256 KB Output is correct
22 Correct 2 ms 2128 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 9 ms 6224 KB Output is correct
25 Correct 24 ms 5092 KB Output is correct
26 Correct 12 ms 2712 KB Output is correct
27 Correct 63 ms 8968 KB Output is correct
28 Correct 16 ms 8528 KB Output is correct
29 Correct 31 ms 8640 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 2128 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 2 ms 2128 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2128 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 1 ms 1360 KB Output is correct
15 Correct 1 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1644 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 1 ms 1104 KB Output is correct
21 Correct 1 ms 2256 KB Output is correct
22 Correct 2 ms 2128 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 9 ms 6224 KB Output is correct
25 Correct 24 ms 5092 KB Output is correct
26 Correct 12 ms 2712 KB Output is correct
27 Correct 63 ms 8968 KB Output is correct
28 Correct 16 ms 8528 KB Output is correct
29 Correct 31 ms 8640 KB Output is correct
30 Correct 27 ms 15368 KB Output is correct
31 Correct 152 ms 98724 KB Output is correct
32 Correct 34 ms 5480 KB Output is correct
33 Correct 12 ms 3092 KB Output is correct
34 Correct 716 ms 78376 KB Output is correct
35 Correct 3730 ms 148632 KB Output is correct
36 Correct 324 ms 16476 KB Output is correct
37 Execution timed out 4048 ms 148604 KB Time limit exceeded
38 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 2128 KB Output is correct
4 Correct 1 ms 1488 KB Output is correct
5 Correct 2 ms 2128 KB Output is correct
6 Correct 2 ms 2128 KB Output is correct
7 Correct 2 ms 2128 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 1 ms 1360 KB Output is correct
15 Correct 1 ms 1232 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 1 ms 1644 KB Output is correct
18 Correct 1 ms 1616 KB Output is correct
19 Correct 1 ms 1616 KB Output is correct
20 Correct 1 ms 1104 KB Output is correct
21 Correct 1 ms 2256 KB Output is correct
22 Correct 2 ms 2128 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 9 ms 6224 KB Output is correct
25 Correct 24 ms 5092 KB Output is correct
26 Correct 12 ms 2712 KB Output is correct
27 Correct 63 ms 8968 KB Output is correct
28 Correct 16 ms 8528 KB Output is correct
29 Correct 31 ms 8640 KB Output is correct
30 Correct 27 ms 15368 KB Output is correct
31 Correct 152 ms 98724 KB Output is correct
32 Correct 34 ms 5480 KB Output is correct
33 Correct 12 ms 3092 KB Output is correct
34 Correct 716 ms 78376 KB Output is correct
35 Correct 3730 ms 148632 KB Output is correct
36 Correct 324 ms 16476 KB Output is correct
37 Execution timed out 4048 ms 148604 KB Time limit exceeded
38 Halted 0 ms 0 KB -