#include "game.h"
#include <string>
#include <algorithm>
#define N 300000
std::basic_string<int> g[N], gt[N];
int n, k, from[N], to[N], cyclic;
/* igo >= goi */
void init(int n_, int k_) {
n = n_, k = k_;
for (int i = 0; i < k; ++i)
to[i] = i, from[i] = i + 1;
for (int i = k; i < n; ++i)
from[i] = k, to[i] = -1;
}
void dfs1(int u, int xx) {
if (from[u] <= xx)
return;
from[u] = xx;
if (to[u] < k && from[u] <= to[u])
cyclic = 1;
for (auto v : gt[u])
dfs1(v, xx);
}
void dfs2(int u, int xx) {
if (to[u] >= xx)
return;
to[u] = xx;
if (to[u] < k && from[u] <= to[u])
cyclic = 1;
for (auto v : g[u])
dfs2(v, xx);
}
#include<stdio.h>
int add_teleporter(int u, int v) {
g[u].push_back(v);
gt[v].push_back(u);
dfs1(u, std::min(v, from[v]));
dfs2(v, to[u]);
return cyclic;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
20312 KB |
Output is correct |
2 |
Correct |
6 ms |
20312 KB |
Output is correct |
3 |
Correct |
5 ms |
20312 KB |
Output is correct |
4 |
Correct |
6 ms |
20312 KB |
Output is correct |
5 |
Correct |
5 ms |
20312 KB |
Output is correct |
6 |
Correct |
5 ms |
20312 KB |
Output is correct |
7 |
Correct |
5 ms |
20312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
20312 KB |
Output is correct |
2 |
Correct |
6 ms |
20312 KB |
Output is correct |
3 |
Correct |
5 ms |
20312 KB |
Output is correct |
4 |
Correct |
6 ms |
20312 KB |
Output is correct |
5 |
Correct |
5 ms |
20312 KB |
Output is correct |
6 |
Correct |
5 ms |
20312 KB |
Output is correct |
7 |
Correct |
5 ms |
20312 KB |
Output is correct |
8 |
Correct |
4 ms |
20312 KB |
Output is correct |
9 |
Correct |
5 ms |
20500 KB |
Output is correct |
10 |
Correct |
5 ms |
20312 KB |
Output is correct |
11 |
Correct |
5 ms |
20568 KB |
Output is correct |
12 |
Correct |
5 ms |
20312 KB |
Output is correct |
13 |
Correct |
6 ms |
20312 KB |
Output is correct |
14 |
Correct |
5 ms |
20312 KB |
Output is correct |
15 |
Correct |
6 ms |
20312 KB |
Output is correct |
16 |
Correct |
4 ms |
20568 KB |
Output is correct |
17 |
Correct |
5 ms |
20400 KB |
Output is correct |
18 |
Correct |
4 ms |
20312 KB |
Output is correct |
19 |
Correct |
4 ms |
20312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
20312 KB |
Output is correct |
2 |
Correct |
6 ms |
20312 KB |
Output is correct |
3 |
Correct |
5 ms |
20312 KB |
Output is correct |
4 |
Correct |
6 ms |
20312 KB |
Output is correct |
5 |
Correct |
5 ms |
20312 KB |
Output is correct |
6 |
Correct |
5 ms |
20312 KB |
Output is correct |
7 |
Correct |
5 ms |
20312 KB |
Output is correct |
8 |
Correct |
4 ms |
20312 KB |
Output is correct |
9 |
Correct |
5 ms |
20500 KB |
Output is correct |
10 |
Correct |
5 ms |
20312 KB |
Output is correct |
11 |
Correct |
5 ms |
20568 KB |
Output is correct |
12 |
Correct |
5 ms |
20312 KB |
Output is correct |
13 |
Correct |
6 ms |
20312 KB |
Output is correct |
14 |
Correct |
5 ms |
20312 KB |
Output is correct |
15 |
Correct |
6 ms |
20312 KB |
Output is correct |
16 |
Correct |
4 ms |
20568 KB |
Output is correct |
17 |
Correct |
5 ms |
20400 KB |
Output is correct |
18 |
Correct |
4 ms |
20312 KB |
Output is correct |
19 |
Correct |
4 ms |
20312 KB |
Output is correct |
20 |
Correct |
5 ms |
20472 KB |
Output is correct |
21 |
Correct |
5 ms |
20312 KB |
Output is correct |
22 |
Correct |
5 ms |
20308 KB |
Output is correct |
23 |
Correct |
4 ms |
20312 KB |
Output is correct |
24 |
Correct |
7 ms |
20568 KB |
Output is correct |
25 |
Correct |
6 ms |
20568 KB |
Output is correct |
26 |
Correct |
6 ms |
20568 KB |
Output is correct |
27 |
Correct |
6 ms |
20568 KB |
Output is correct |
28 |
Correct |
5 ms |
20568 KB |
Output is correct |
29 |
Correct |
6 ms |
20568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
20312 KB |
Output is correct |
2 |
Correct |
6 ms |
20312 KB |
Output is correct |
3 |
Correct |
5 ms |
20312 KB |
Output is correct |
4 |
Correct |
6 ms |
20312 KB |
Output is correct |
5 |
Correct |
5 ms |
20312 KB |
Output is correct |
6 |
Correct |
5 ms |
20312 KB |
Output is correct |
7 |
Correct |
5 ms |
20312 KB |
Output is correct |
8 |
Correct |
4 ms |
20312 KB |
Output is correct |
9 |
Correct |
5 ms |
20500 KB |
Output is correct |
10 |
Correct |
5 ms |
20312 KB |
Output is correct |
11 |
Correct |
5 ms |
20568 KB |
Output is correct |
12 |
Correct |
5 ms |
20312 KB |
Output is correct |
13 |
Correct |
6 ms |
20312 KB |
Output is correct |
14 |
Correct |
5 ms |
20312 KB |
Output is correct |
15 |
Correct |
6 ms |
20312 KB |
Output is correct |
16 |
Correct |
4 ms |
20568 KB |
Output is correct |
17 |
Correct |
5 ms |
20400 KB |
Output is correct |
18 |
Correct |
4 ms |
20312 KB |
Output is correct |
19 |
Correct |
4 ms |
20312 KB |
Output is correct |
20 |
Correct |
5 ms |
20472 KB |
Output is correct |
21 |
Correct |
5 ms |
20312 KB |
Output is correct |
22 |
Correct |
5 ms |
20308 KB |
Output is correct |
23 |
Correct |
4 ms |
20312 KB |
Output is correct |
24 |
Correct |
7 ms |
20568 KB |
Output is correct |
25 |
Correct |
6 ms |
20568 KB |
Output is correct |
26 |
Correct |
6 ms |
20568 KB |
Output is correct |
27 |
Correct |
6 ms |
20568 KB |
Output is correct |
28 |
Correct |
5 ms |
20568 KB |
Output is correct |
29 |
Correct |
6 ms |
20568 KB |
Output is correct |
30 |
Correct |
14 ms |
21084 KB |
Output is correct |
31 |
Correct |
7 ms |
20568 KB |
Output is correct |
32 |
Correct |
16 ms |
21336 KB |
Output is correct |
33 |
Correct |
12 ms |
20568 KB |
Output is correct |
34 |
Correct |
517 ms |
22168 KB |
Output is correct |
35 |
Correct |
194 ms |
21476 KB |
Output is correct |
36 |
Correct |
24 ms |
20904 KB |
Output is correct |
37 |
Correct |
20 ms |
21076 KB |
Output is correct |
38 |
Correct |
20 ms |
20840 KB |
Output is correct |
39 |
Correct |
24 ms |
21428 KB |
Output is correct |
40 |
Correct |
484 ms |
22620 KB |
Output is correct |
41 |
Correct |
89 ms |
21736 KB |
Output is correct |
42 |
Correct |
64 ms |
21740 KB |
Output is correct |
43 |
Correct |
26 ms |
22168 KB |
Output is correct |
44 |
Correct |
380 ms |
22104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
20312 KB |
Output is correct |
2 |
Correct |
6 ms |
20312 KB |
Output is correct |
3 |
Correct |
5 ms |
20312 KB |
Output is correct |
4 |
Correct |
6 ms |
20312 KB |
Output is correct |
5 |
Correct |
5 ms |
20312 KB |
Output is correct |
6 |
Correct |
5 ms |
20312 KB |
Output is correct |
7 |
Correct |
5 ms |
20312 KB |
Output is correct |
8 |
Correct |
4 ms |
20312 KB |
Output is correct |
9 |
Correct |
5 ms |
20500 KB |
Output is correct |
10 |
Correct |
5 ms |
20312 KB |
Output is correct |
11 |
Correct |
5 ms |
20568 KB |
Output is correct |
12 |
Correct |
5 ms |
20312 KB |
Output is correct |
13 |
Correct |
6 ms |
20312 KB |
Output is correct |
14 |
Correct |
5 ms |
20312 KB |
Output is correct |
15 |
Correct |
6 ms |
20312 KB |
Output is correct |
16 |
Correct |
4 ms |
20568 KB |
Output is correct |
17 |
Correct |
5 ms |
20400 KB |
Output is correct |
18 |
Correct |
4 ms |
20312 KB |
Output is correct |
19 |
Correct |
4 ms |
20312 KB |
Output is correct |
20 |
Correct |
5 ms |
20472 KB |
Output is correct |
21 |
Correct |
5 ms |
20312 KB |
Output is correct |
22 |
Correct |
5 ms |
20308 KB |
Output is correct |
23 |
Correct |
4 ms |
20312 KB |
Output is correct |
24 |
Correct |
7 ms |
20568 KB |
Output is correct |
25 |
Correct |
6 ms |
20568 KB |
Output is correct |
26 |
Correct |
6 ms |
20568 KB |
Output is correct |
27 |
Correct |
6 ms |
20568 KB |
Output is correct |
28 |
Correct |
5 ms |
20568 KB |
Output is correct |
29 |
Correct |
6 ms |
20568 KB |
Output is correct |
30 |
Correct |
14 ms |
21084 KB |
Output is correct |
31 |
Correct |
7 ms |
20568 KB |
Output is correct |
32 |
Correct |
16 ms |
21336 KB |
Output is correct |
33 |
Correct |
12 ms |
20568 KB |
Output is correct |
34 |
Correct |
517 ms |
22168 KB |
Output is correct |
35 |
Correct |
194 ms |
21476 KB |
Output is correct |
36 |
Correct |
24 ms |
20904 KB |
Output is correct |
37 |
Correct |
20 ms |
21076 KB |
Output is correct |
38 |
Correct |
20 ms |
20840 KB |
Output is correct |
39 |
Correct |
24 ms |
21428 KB |
Output is correct |
40 |
Correct |
484 ms |
22620 KB |
Output is correct |
41 |
Correct |
89 ms |
21736 KB |
Output is correct |
42 |
Correct |
64 ms |
21740 KB |
Output is correct |
43 |
Correct |
26 ms |
22168 KB |
Output is correct |
44 |
Correct |
380 ms |
22104 KB |
Output is correct |
45 |
Correct |
110 ms |
22632 KB |
Output is correct |
46 |
Correct |
8 ms |
21336 KB |
Output is correct |
47 |
Correct |
8 ms |
21336 KB |
Output is correct |
48 |
Correct |
170 ms |
28448 KB |
Output is correct |
49 |
Correct |
115 ms |
21552 KB |
Output is correct |
50 |
Execution timed out |
4080 ms |
28584 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |