#include "game.h"
#include <vector>
#include <cstdio>
#define PB push_back
using namespace std;
const int N = 5e5 + 500;
int n, k, ans;
vector < int > v[N], r[N];
int L[N], R[N];
void init(int _n, int _k) {
n = _n, k = _k;
for(int i = 0;i < n;i++)
L[i] = -1, R[i] = n;
for(int i = 0;i < k;i++)
L[i] = i, R[i] = i;
}
void noviL(int x, int vr){
L[x] = vr;
for(int y : v[x])
if(L[y] < vr) noviL(y, vr);
}
void noviR(int x, int vr){
R[x] = vr;
for(int y : r[x])
if(R[y] > vr) noviR(y, vr);
}
int add_teleporter(int a, int b) {
v[a].PB(b), r[b].PB(a);
if(a == b && a < k) ans = 1;
if(L[b] < L[a]) noviL(b, L[a]);
if(R[a] > R[b]) noviR(a, R[b]);
ans |= L[a] > R[a];
ans |= L[b] > R[b];
if(a >= k) ans |= L[a] == R[a];
if(b >= k) ans |= L[b] == R[b];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
12 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23740 KB |
Output is correct |
4 |
Correct |
12 ms |
23760 KB |
Output is correct |
5 |
Correct |
12 ms |
23708 KB |
Output is correct |
6 |
Correct |
13 ms |
23760 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
12 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23740 KB |
Output is correct |
4 |
Correct |
12 ms |
23760 KB |
Output is correct |
5 |
Correct |
12 ms |
23708 KB |
Output is correct |
6 |
Correct |
13 ms |
23760 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Correct |
11 ms |
23760 KB |
Output is correct |
9 |
Correct |
13 ms |
23760 KB |
Output is correct |
10 |
Correct |
12 ms |
23760 KB |
Output is correct |
11 |
Correct |
11 ms |
23792 KB |
Output is correct |
12 |
Correct |
12 ms |
23760 KB |
Output is correct |
13 |
Correct |
14 ms |
23760 KB |
Output is correct |
14 |
Correct |
12 ms |
23760 KB |
Output is correct |
15 |
Correct |
13 ms |
23884 KB |
Output is correct |
16 |
Correct |
12 ms |
23760 KB |
Output is correct |
17 |
Correct |
12 ms |
23760 KB |
Output is correct |
18 |
Correct |
12 ms |
23800 KB |
Output is correct |
19 |
Correct |
12 ms |
23756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
12 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23740 KB |
Output is correct |
4 |
Correct |
12 ms |
23760 KB |
Output is correct |
5 |
Correct |
12 ms |
23708 KB |
Output is correct |
6 |
Correct |
13 ms |
23760 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Correct |
11 ms |
23760 KB |
Output is correct |
9 |
Correct |
13 ms |
23760 KB |
Output is correct |
10 |
Correct |
12 ms |
23760 KB |
Output is correct |
11 |
Correct |
11 ms |
23792 KB |
Output is correct |
12 |
Correct |
12 ms |
23760 KB |
Output is correct |
13 |
Correct |
14 ms |
23760 KB |
Output is correct |
14 |
Correct |
12 ms |
23760 KB |
Output is correct |
15 |
Correct |
13 ms |
23884 KB |
Output is correct |
16 |
Correct |
12 ms |
23760 KB |
Output is correct |
17 |
Correct |
12 ms |
23760 KB |
Output is correct |
18 |
Correct |
12 ms |
23800 KB |
Output is correct |
19 |
Correct |
12 ms |
23756 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
11 ms |
23820 KB |
Output is correct |
22 |
Correct |
12 ms |
23824 KB |
Output is correct |
23 |
Correct |
12 ms |
23760 KB |
Output is correct |
24 |
Correct |
16 ms |
23872 KB |
Output is correct |
25 |
Correct |
16 ms |
23912 KB |
Output is correct |
26 |
Correct |
14 ms |
23884 KB |
Output is correct |
27 |
Correct |
14 ms |
23824 KB |
Output is correct |
28 |
Correct |
13 ms |
23760 KB |
Output is correct |
29 |
Correct |
18 ms |
23888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
12 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23740 KB |
Output is correct |
4 |
Correct |
12 ms |
23760 KB |
Output is correct |
5 |
Correct |
12 ms |
23708 KB |
Output is correct |
6 |
Correct |
13 ms |
23760 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Correct |
11 ms |
23760 KB |
Output is correct |
9 |
Correct |
13 ms |
23760 KB |
Output is correct |
10 |
Correct |
12 ms |
23760 KB |
Output is correct |
11 |
Correct |
11 ms |
23792 KB |
Output is correct |
12 |
Correct |
12 ms |
23760 KB |
Output is correct |
13 |
Correct |
14 ms |
23760 KB |
Output is correct |
14 |
Correct |
12 ms |
23760 KB |
Output is correct |
15 |
Correct |
13 ms |
23884 KB |
Output is correct |
16 |
Correct |
12 ms |
23760 KB |
Output is correct |
17 |
Correct |
12 ms |
23760 KB |
Output is correct |
18 |
Correct |
12 ms |
23800 KB |
Output is correct |
19 |
Correct |
12 ms |
23756 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
11 ms |
23820 KB |
Output is correct |
22 |
Correct |
12 ms |
23824 KB |
Output is correct |
23 |
Correct |
12 ms |
23760 KB |
Output is correct |
24 |
Correct |
16 ms |
23872 KB |
Output is correct |
25 |
Correct |
16 ms |
23912 KB |
Output is correct |
26 |
Correct |
14 ms |
23884 KB |
Output is correct |
27 |
Correct |
14 ms |
23824 KB |
Output is correct |
28 |
Correct |
13 ms |
23760 KB |
Output is correct |
29 |
Correct |
18 ms |
23888 KB |
Output is correct |
30 |
Correct |
26 ms |
25064 KB |
Output is correct |
31 |
Correct |
16 ms |
24400 KB |
Output is correct |
32 |
Correct |
32 ms |
26064 KB |
Output is correct |
33 |
Correct |
29 ms |
25908 KB |
Output is correct |
34 |
Correct |
985 ms |
26552 KB |
Output is correct |
35 |
Correct |
349 ms |
26212 KB |
Output is correct |
36 |
Correct |
42 ms |
25848 KB |
Output is correct |
37 |
Correct |
59 ms |
25760 KB |
Output is correct |
38 |
Correct |
45 ms |
25572 KB |
Output is correct |
39 |
Correct |
52 ms |
25576 KB |
Output is correct |
40 |
Correct |
782 ms |
26680 KB |
Output is correct |
41 |
Correct |
159 ms |
25816 KB |
Output is correct |
42 |
Correct |
111 ms |
25704 KB |
Output is correct |
43 |
Correct |
61 ms |
26544 KB |
Output is correct |
44 |
Correct |
698 ms |
26352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
12 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23740 KB |
Output is correct |
4 |
Correct |
12 ms |
23760 KB |
Output is correct |
5 |
Correct |
12 ms |
23708 KB |
Output is correct |
6 |
Correct |
13 ms |
23760 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Correct |
11 ms |
23760 KB |
Output is correct |
9 |
Correct |
13 ms |
23760 KB |
Output is correct |
10 |
Correct |
12 ms |
23760 KB |
Output is correct |
11 |
Correct |
11 ms |
23792 KB |
Output is correct |
12 |
Correct |
12 ms |
23760 KB |
Output is correct |
13 |
Correct |
14 ms |
23760 KB |
Output is correct |
14 |
Correct |
12 ms |
23760 KB |
Output is correct |
15 |
Correct |
13 ms |
23884 KB |
Output is correct |
16 |
Correct |
12 ms |
23760 KB |
Output is correct |
17 |
Correct |
12 ms |
23760 KB |
Output is correct |
18 |
Correct |
12 ms |
23800 KB |
Output is correct |
19 |
Correct |
12 ms |
23756 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
11 ms |
23820 KB |
Output is correct |
22 |
Correct |
12 ms |
23824 KB |
Output is correct |
23 |
Correct |
12 ms |
23760 KB |
Output is correct |
24 |
Correct |
16 ms |
23872 KB |
Output is correct |
25 |
Correct |
16 ms |
23912 KB |
Output is correct |
26 |
Correct |
14 ms |
23884 KB |
Output is correct |
27 |
Correct |
14 ms |
23824 KB |
Output is correct |
28 |
Correct |
13 ms |
23760 KB |
Output is correct |
29 |
Correct |
18 ms |
23888 KB |
Output is correct |
30 |
Correct |
26 ms |
25064 KB |
Output is correct |
31 |
Correct |
16 ms |
24400 KB |
Output is correct |
32 |
Correct |
32 ms |
26064 KB |
Output is correct |
33 |
Correct |
29 ms |
25908 KB |
Output is correct |
34 |
Correct |
985 ms |
26552 KB |
Output is correct |
35 |
Correct |
349 ms |
26212 KB |
Output is correct |
36 |
Correct |
42 ms |
25848 KB |
Output is correct |
37 |
Correct |
59 ms |
25760 KB |
Output is correct |
38 |
Correct |
45 ms |
25572 KB |
Output is correct |
39 |
Correct |
52 ms |
25576 KB |
Output is correct |
40 |
Correct |
782 ms |
26680 KB |
Output is correct |
41 |
Correct |
159 ms |
25816 KB |
Output is correct |
42 |
Correct |
111 ms |
25704 KB |
Output is correct |
43 |
Correct |
61 ms |
26544 KB |
Output is correct |
44 |
Correct |
698 ms |
26352 KB |
Output is correct |
45 |
Correct |
237 ms |
37452 KB |
Output is correct |
46 |
Correct |
20 ms |
26540 KB |
Output is correct |
47 |
Correct |
21 ms |
26440 KB |
Output is correct |
48 |
Correct |
360 ms |
47712 KB |
Output is correct |
49 |
Correct |
292 ms |
44988 KB |
Output is correct |
50 |
Execution timed out |
4041 ms |
38508 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |