#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int mxN = (int)2e5+10;
int n, k, L[mxN], R[mxN];
vector<int> adj[mxN], radj[mxN];
void init(int N, int K) {
n = N; k = K;
for(int i = 0; i < k; i++) L[i]=R[i]=i;
for(int i = k; i < n; i++) L[i]=n,R[i]=-1;
}
void dfs(int s, int c, vector<int> adj[], bool ok){
if(ok){
if(c<k and R[s]<c) R[s]=c;
else return;
}
else{
if(L[s]>c) L[s]=c;
else return;
}
for(auto u : adj[s]) dfs(u,c,adj,ok);
}
int add_teleporter(int u, int v) {
if(u>=v and u<k) return 1;
if(max(u,v)<k) return 0;
adj[u].pb(v), radj[v].pb(u);
dfs(u, L[v], radj,0), dfs(v,R[u], adj,1);
return (L[v]<=R[u] and R[u]<k);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9680 KB |
Output is correct |
2 |
Correct |
6 ms |
9616 KB |
Output is correct |
3 |
Correct |
6 ms |
9680 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
6 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9668 KB |
Output is correct |
7 |
Correct |
6 ms |
9680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9680 KB |
Output is correct |
2 |
Correct |
6 ms |
9616 KB |
Output is correct |
3 |
Correct |
6 ms |
9680 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
6 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9668 KB |
Output is correct |
7 |
Correct |
6 ms |
9680 KB |
Output is correct |
8 |
Correct |
5 ms |
9680 KB |
Output is correct |
9 |
Correct |
7 ms |
9628 KB |
Output is correct |
10 |
Correct |
5 ms |
9680 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
6 ms |
9680 KB |
Output is correct |
13 |
Correct |
6 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9700 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
6 ms |
9624 KB |
Output is correct |
17 |
Correct |
5 ms |
9596 KB |
Output is correct |
18 |
Correct |
5 ms |
9696 KB |
Output is correct |
19 |
Correct |
6 ms |
9680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9680 KB |
Output is correct |
2 |
Correct |
6 ms |
9616 KB |
Output is correct |
3 |
Correct |
6 ms |
9680 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
6 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9668 KB |
Output is correct |
7 |
Correct |
6 ms |
9680 KB |
Output is correct |
8 |
Correct |
5 ms |
9680 KB |
Output is correct |
9 |
Correct |
7 ms |
9628 KB |
Output is correct |
10 |
Correct |
5 ms |
9680 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
6 ms |
9680 KB |
Output is correct |
13 |
Correct |
6 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9700 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
6 ms |
9624 KB |
Output is correct |
17 |
Correct |
5 ms |
9596 KB |
Output is correct |
18 |
Correct |
5 ms |
9696 KB |
Output is correct |
19 |
Correct |
6 ms |
9680 KB |
Output is correct |
20 |
Correct |
7 ms |
9692 KB |
Output is correct |
21 |
Correct |
5 ms |
9680 KB |
Output is correct |
22 |
Correct |
7 ms |
9736 KB |
Output is correct |
23 |
Correct |
6 ms |
9724 KB |
Output is correct |
24 |
Correct |
11 ms |
9680 KB |
Output is correct |
25 |
Correct |
10 ms |
9804 KB |
Output is correct |
26 |
Correct |
7 ms |
9808 KB |
Output is correct |
27 |
Correct |
7 ms |
9680 KB |
Output is correct |
28 |
Correct |
7 ms |
9680 KB |
Output is correct |
29 |
Correct |
7 ms |
9728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9680 KB |
Output is correct |
2 |
Correct |
6 ms |
9616 KB |
Output is correct |
3 |
Correct |
6 ms |
9680 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
6 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9668 KB |
Output is correct |
7 |
Correct |
6 ms |
9680 KB |
Output is correct |
8 |
Correct |
5 ms |
9680 KB |
Output is correct |
9 |
Correct |
7 ms |
9628 KB |
Output is correct |
10 |
Correct |
5 ms |
9680 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
6 ms |
9680 KB |
Output is correct |
13 |
Correct |
6 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9700 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
6 ms |
9624 KB |
Output is correct |
17 |
Correct |
5 ms |
9596 KB |
Output is correct |
18 |
Correct |
5 ms |
9696 KB |
Output is correct |
19 |
Correct |
6 ms |
9680 KB |
Output is correct |
20 |
Correct |
7 ms |
9692 KB |
Output is correct |
21 |
Correct |
5 ms |
9680 KB |
Output is correct |
22 |
Correct |
7 ms |
9736 KB |
Output is correct |
23 |
Correct |
6 ms |
9724 KB |
Output is correct |
24 |
Correct |
11 ms |
9680 KB |
Output is correct |
25 |
Correct |
10 ms |
9804 KB |
Output is correct |
26 |
Correct |
7 ms |
9808 KB |
Output is correct |
27 |
Correct |
7 ms |
9680 KB |
Output is correct |
28 |
Correct |
7 ms |
9680 KB |
Output is correct |
29 |
Correct |
7 ms |
9728 KB |
Output is correct |
30 |
Correct |
25 ms |
10984 KB |
Output is correct |
31 |
Correct |
12 ms |
10320 KB |
Output is correct |
32 |
Correct |
39 ms |
12380 KB |
Output is correct |
33 |
Correct |
26 ms |
11804 KB |
Output is correct |
34 |
Correct |
1035 ms |
13132 KB |
Output is correct |
35 |
Correct |
349 ms |
12280 KB |
Output is correct |
36 |
Correct |
42 ms |
11772 KB |
Output is correct |
37 |
Correct |
48 ms |
11776 KB |
Output is correct |
38 |
Correct |
49 ms |
11552 KB |
Output is correct |
39 |
Correct |
36 ms |
11516 KB |
Output is correct |
40 |
Correct |
927 ms |
13192 KB |
Output is correct |
41 |
Correct |
188 ms |
11924 KB |
Output is correct |
42 |
Correct |
130 ms |
11764 KB |
Output is correct |
43 |
Correct |
51 ms |
13216 KB |
Output is correct |
44 |
Correct |
866 ms |
13136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9680 KB |
Output is correct |
2 |
Correct |
6 ms |
9616 KB |
Output is correct |
3 |
Correct |
6 ms |
9680 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
6 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9668 KB |
Output is correct |
7 |
Correct |
6 ms |
9680 KB |
Output is correct |
8 |
Correct |
5 ms |
9680 KB |
Output is correct |
9 |
Correct |
7 ms |
9628 KB |
Output is correct |
10 |
Correct |
5 ms |
9680 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
6 ms |
9680 KB |
Output is correct |
13 |
Correct |
6 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9700 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
6 ms |
9624 KB |
Output is correct |
17 |
Correct |
5 ms |
9596 KB |
Output is correct |
18 |
Correct |
5 ms |
9696 KB |
Output is correct |
19 |
Correct |
6 ms |
9680 KB |
Output is correct |
20 |
Correct |
7 ms |
9692 KB |
Output is correct |
21 |
Correct |
5 ms |
9680 KB |
Output is correct |
22 |
Correct |
7 ms |
9736 KB |
Output is correct |
23 |
Correct |
6 ms |
9724 KB |
Output is correct |
24 |
Correct |
11 ms |
9680 KB |
Output is correct |
25 |
Correct |
10 ms |
9804 KB |
Output is correct |
26 |
Correct |
7 ms |
9808 KB |
Output is correct |
27 |
Correct |
7 ms |
9680 KB |
Output is correct |
28 |
Correct |
7 ms |
9680 KB |
Output is correct |
29 |
Correct |
7 ms |
9728 KB |
Output is correct |
30 |
Correct |
25 ms |
10984 KB |
Output is correct |
31 |
Correct |
12 ms |
10320 KB |
Output is correct |
32 |
Correct |
39 ms |
12380 KB |
Output is correct |
33 |
Correct |
26 ms |
11804 KB |
Output is correct |
34 |
Correct |
1035 ms |
13132 KB |
Output is correct |
35 |
Correct |
349 ms |
12280 KB |
Output is correct |
36 |
Correct |
42 ms |
11772 KB |
Output is correct |
37 |
Correct |
48 ms |
11776 KB |
Output is correct |
38 |
Correct |
49 ms |
11552 KB |
Output is correct |
39 |
Correct |
36 ms |
11516 KB |
Output is correct |
40 |
Correct |
927 ms |
13192 KB |
Output is correct |
41 |
Correct |
188 ms |
11924 KB |
Output is correct |
42 |
Correct |
130 ms |
11764 KB |
Output is correct |
43 |
Correct |
51 ms |
13216 KB |
Output is correct |
44 |
Correct |
866 ms |
13136 KB |
Output is correct |
45 |
Runtime error |
14 ms |
20940 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |