#include "game.h"
#include <bitset>
#include <queue>
#include <vector>
using std::bitset;
using std::queue;
using std::vector;
constexpr int MAX_N = 30000;
int N, K;
vector<vector<int>> graph;
vector<bitset<MAX_N>> visited;
void init(int N, int K) {
::N = N;
::K = K;
graph.assign(N, vector<int>());
visited.assign(K, bitset<MAX_N>());
for (int x = 0; x < K; ++x) {
visited[x].set(x);
}
}
int add_teleporter(int u, int v) {
graph[u].push_back(v);
for (int k = 0; k < K; ++k) {
if (visited[k][u]) {
queue<int> q;
q.push(v);
for (; !q.empty(); ) {
const int x = q.front();
q.pop();
if (x <= k) {
return 1;
}
if (!visited[k][x]) {
visited[k].set(x);
for (const int y : graph[x]) {
q.push(y);
}
}
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
592 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
592 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
0 ms |
464 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
1 ms |
464 KB |
Output is correct |
19 |
Correct |
0 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
592 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
0 ms |
464 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
1 ms |
464 KB |
Output is correct |
19 |
Correct |
0 ms |
464 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
0 ms |
592 KB |
Output is correct |
22 |
Correct |
1 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
7 ms |
2128 KB |
Output is correct |
25 |
Correct |
7 ms |
1232 KB |
Output is correct |
26 |
Correct |
9 ms |
720 KB |
Output is correct |
27 |
Correct |
8 ms |
2128 KB |
Output is correct |
28 |
Correct |
4 ms |
2000 KB |
Output is correct |
29 |
Correct |
9 ms |
2128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
592 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
0 ms |
464 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
1 ms |
464 KB |
Output is correct |
19 |
Correct |
0 ms |
464 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
0 ms |
592 KB |
Output is correct |
22 |
Correct |
1 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
7 ms |
2128 KB |
Output is correct |
25 |
Correct |
7 ms |
1232 KB |
Output is correct |
26 |
Correct |
9 ms |
720 KB |
Output is correct |
27 |
Correct |
8 ms |
2128 KB |
Output is correct |
28 |
Correct |
4 ms |
2000 KB |
Output is correct |
29 |
Correct |
9 ms |
2128 KB |
Output is correct |
30 |
Correct |
15 ms |
1880 KB |
Output is correct |
31 |
Correct |
19 ms |
4808 KB |
Output is correct |
32 |
Correct |
17 ms |
2280 KB |
Output is correct |
33 |
Correct |
12 ms |
1864 KB |
Output is correct |
34 |
Correct |
552 ms |
5708 KB |
Output is correct |
35 |
Correct |
535 ms |
5648 KB |
Output is correct |
36 |
Correct |
56 ms |
2192 KB |
Output is correct |
37 |
Correct |
302 ms |
5560 KB |
Output is correct |
38 |
Correct |
313 ms |
5348 KB |
Output is correct |
39 |
Correct |
457 ms |
5376 KB |
Output is correct |
40 |
Correct |
536 ms |
5704 KB |
Output is correct |
41 |
Correct |
247 ms |
5512 KB |
Output is correct |
42 |
Correct |
247 ms |
5392 KB |
Output is correct |
43 |
Correct |
698 ms |
5744 KB |
Output is correct |
44 |
Correct |
272 ms |
5516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
592 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
0 ms |
464 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
1 ms |
464 KB |
Output is correct |
19 |
Correct |
0 ms |
464 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
0 ms |
592 KB |
Output is correct |
22 |
Correct |
1 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
7 ms |
2128 KB |
Output is correct |
25 |
Correct |
7 ms |
1232 KB |
Output is correct |
26 |
Correct |
9 ms |
720 KB |
Output is correct |
27 |
Correct |
8 ms |
2128 KB |
Output is correct |
28 |
Correct |
4 ms |
2000 KB |
Output is correct |
29 |
Correct |
9 ms |
2128 KB |
Output is correct |
30 |
Correct |
15 ms |
1880 KB |
Output is correct |
31 |
Correct |
19 ms |
4808 KB |
Output is correct |
32 |
Correct |
17 ms |
2280 KB |
Output is correct |
33 |
Correct |
12 ms |
1864 KB |
Output is correct |
34 |
Correct |
552 ms |
5708 KB |
Output is correct |
35 |
Correct |
535 ms |
5648 KB |
Output is correct |
36 |
Correct |
56 ms |
2192 KB |
Output is correct |
37 |
Correct |
302 ms |
5560 KB |
Output is correct |
38 |
Correct |
313 ms |
5348 KB |
Output is correct |
39 |
Correct |
457 ms |
5376 KB |
Output is correct |
40 |
Correct |
536 ms |
5704 KB |
Output is correct |
41 |
Correct |
247 ms |
5512 KB |
Output is correct |
42 |
Correct |
247 ms |
5392 KB |
Output is correct |
43 |
Correct |
698 ms |
5744 KB |
Output is correct |
44 |
Correct |
272 ms |
5516 KB |
Output is correct |
45 |
Runtime error |
11 ms |
15368 KB |
Execution killed with signal 6 |
46 |
Halted |
0 ms |
0 KB |
- |