#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int mxN = (int)2e5+10;
int n, k, sm[mxN], bg[mxN];
vector<int> adj[mxN], radj[mxN];
void init(int N, int K) {
n = N; k = K;
for(int i = 0; i < k; i++)
sm[i]=bg[i] =i;
for(int i = k; i < n; i++)
sm[i] = n, bg[i] = -1;
}
void dfs(int s, int c, vector<int> adj[], bool ok){
if(ok){
if(c>=k) return;
if(bg[s]>=c) return;
bg[s] = c;
}
else{
if(sm[s]<=c) return;
sm[s] = c;
}
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, sm[v], radj,0), dfs(v,bg[u], adj,1);
return (sm[v]<=bg[u] and bg[u]<k);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9692 KB |
Output is correct |
2 |
Correct |
5 ms |
9608 KB |
Output is correct |
3 |
Correct |
5 ms |
9592 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
5 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9680 KB |
Output is correct |
7 |
Correct |
5 ms |
9680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9692 KB |
Output is correct |
2 |
Correct |
5 ms |
9608 KB |
Output is correct |
3 |
Correct |
5 ms |
9592 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
5 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9680 KB |
Output is correct |
7 |
Correct |
5 ms |
9680 KB |
Output is correct |
8 |
Correct |
6 ms |
9680 KB |
Output is correct |
9 |
Correct |
5 ms |
9680 KB |
Output is correct |
10 |
Correct |
7 ms |
9600 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
5 ms |
9680 KB |
Output is correct |
13 |
Correct |
5 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9680 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
5 ms |
9616 KB |
Output is correct |
17 |
Correct |
5 ms |
9680 KB |
Output is correct |
18 |
Correct |
5 ms |
9680 KB |
Output is correct |
19 |
Correct |
5 ms |
9680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9692 KB |
Output is correct |
2 |
Correct |
5 ms |
9608 KB |
Output is correct |
3 |
Correct |
5 ms |
9592 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
5 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9680 KB |
Output is correct |
7 |
Correct |
5 ms |
9680 KB |
Output is correct |
8 |
Correct |
6 ms |
9680 KB |
Output is correct |
9 |
Correct |
5 ms |
9680 KB |
Output is correct |
10 |
Correct |
7 ms |
9600 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
5 ms |
9680 KB |
Output is correct |
13 |
Correct |
5 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9680 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
5 ms |
9616 KB |
Output is correct |
17 |
Correct |
5 ms |
9680 KB |
Output is correct |
18 |
Correct |
5 ms |
9680 KB |
Output is correct |
19 |
Correct |
5 ms |
9680 KB |
Output is correct |
20 |
Correct |
6 ms |
9652 KB |
Output is correct |
21 |
Correct |
6 ms |
9680 KB |
Output is correct |
22 |
Correct |
6 ms |
9680 KB |
Output is correct |
23 |
Correct |
8 ms |
9724 KB |
Output is correct |
24 |
Correct |
9 ms |
9680 KB |
Output is correct |
25 |
Correct |
8 ms |
9808 KB |
Output is correct |
26 |
Correct |
8 ms |
9808 KB |
Output is correct |
27 |
Correct |
8 ms |
9752 KB |
Output is correct |
28 |
Correct |
6 ms |
9680 KB |
Output is correct |
29 |
Correct |
6 ms |
9724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9692 KB |
Output is correct |
2 |
Correct |
5 ms |
9608 KB |
Output is correct |
3 |
Correct |
5 ms |
9592 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
5 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9680 KB |
Output is correct |
7 |
Correct |
5 ms |
9680 KB |
Output is correct |
8 |
Correct |
6 ms |
9680 KB |
Output is correct |
9 |
Correct |
5 ms |
9680 KB |
Output is correct |
10 |
Correct |
7 ms |
9600 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
5 ms |
9680 KB |
Output is correct |
13 |
Correct |
5 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9680 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
5 ms |
9616 KB |
Output is correct |
17 |
Correct |
5 ms |
9680 KB |
Output is correct |
18 |
Correct |
5 ms |
9680 KB |
Output is correct |
19 |
Correct |
5 ms |
9680 KB |
Output is correct |
20 |
Correct |
6 ms |
9652 KB |
Output is correct |
21 |
Correct |
6 ms |
9680 KB |
Output is correct |
22 |
Correct |
6 ms |
9680 KB |
Output is correct |
23 |
Correct |
8 ms |
9724 KB |
Output is correct |
24 |
Correct |
9 ms |
9680 KB |
Output is correct |
25 |
Correct |
8 ms |
9808 KB |
Output is correct |
26 |
Correct |
8 ms |
9808 KB |
Output is correct |
27 |
Correct |
8 ms |
9752 KB |
Output is correct |
28 |
Correct |
6 ms |
9680 KB |
Output is correct |
29 |
Correct |
6 ms |
9724 KB |
Output is correct |
30 |
Correct |
21 ms |
11080 KB |
Output is correct |
31 |
Correct |
10 ms |
10244 KB |
Output is correct |
32 |
Correct |
25 ms |
12636 KB |
Output is correct |
33 |
Correct |
20 ms |
11760 KB |
Output is correct |
34 |
Correct |
1067 ms |
13128 KB |
Output is correct |
35 |
Correct |
361 ms |
12436 KB |
Output is correct |
36 |
Correct |
42 ms |
11692 KB |
Output is correct |
37 |
Correct |
34 ms |
11736 KB |
Output is correct |
38 |
Correct |
46 ms |
11480 KB |
Output is correct |
39 |
Correct |
32 ms |
11592 KB |
Output is correct |
40 |
Correct |
962 ms |
13200 KB |
Output is correct |
41 |
Correct |
173 ms |
11896 KB |
Output is correct |
42 |
Correct |
107 ms |
11884 KB |
Output is correct |
43 |
Correct |
46 ms |
13220 KB |
Output is correct |
44 |
Correct |
835 ms |
13128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9692 KB |
Output is correct |
2 |
Correct |
5 ms |
9608 KB |
Output is correct |
3 |
Correct |
5 ms |
9592 KB |
Output is correct |
4 |
Correct |
5 ms |
9680 KB |
Output is correct |
5 |
Correct |
5 ms |
9680 KB |
Output is correct |
6 |
Correct |
6 ms |
9680 KB |
Output is correct |
7 |
Correct |
5 ms |
9680 KB |
Output is correct |
8 |
Correct |
6 ms |
9680 KB |
Output is correct |
9 |
Correct |
5 ms |
9680 KB |
Output is correct |
10 |
Correct |
7 ms |
9600 KB |
Output is correct |
11 |
Correct |
5 ms |
9680 KB |
Output is correct |
12 |
Correct |
5 ms |
9680 KB |
Output is correct |
13 |
Correct |
5 ms |
9680 KB |
Output is correct |
14 |
Correct |
5 ms |
9680 KB |
Output is correct |
15 |
Correct |
5 ms |
9680 KB |
Output is correct |
16 |
Correct |
5 ms |
9616 KB |
Output is correct |
17 |
Correct |
5 ms |
9680 KB |
Output is correct |
18 |
Correct |
5 ms |
9680 KB |
Output is correct |
19 |
Correct |
5 ms |
9680 KB |
Output is correct |
20 |
Correct |
6 ms |
9652 KB |
Output is correct |
21 |
Correct |
6 ms |
9680 KB |
Output is correct |
22 |
Correct |
6 ms |
9680 KB |
Output is correct |
23 |
Correct |
8 ms |
9724 KB |
Output is correct |
24 |
Correct |
9 ms |
9680 KB |
Output is correct |
25 |
Correct |
8 ms |
9808 KB |
Output is correct |
26 |
Correct |
8 ms |
9808 KB |
Output is correct |
27 |
Correct |
8 ms |
9752 KB |
Output is correct |
28 |
Correct |
6 ms |
9680 KB |
Output is correct |
29 |
Correct |
6 ms |
9724 KB |
Output is correct |
30 |
Correct |
21 ms |
11080 KB |
Output is correct |
31 |
Correct |
10 ms |
10244 KB |
Output is correct |
32 |
Correct |
25 ms |
12636 KB |
Output is correct |
33 |
Correct |
20 ms |
11760 KB |
Output is correct |
34 |
Correct |
1067 ms |
13128 KB |
Output is correct |
35 |
Correct |
361 ms |
12436 KB |
Output is correct |
36 |
Correct |
42 ms |
11692 KB |
Output is correct |
37 |
Correct |
34 ms |
11736 KB |
Output is correct |
38 |
Correct |
46 ms |
11480 KB |
Output is correct |
39 |
Correct |
32 ms |
11592 KB |
Output is correct |
40 |
Correct |
962 ms |
13200 KB |
Output is correct |
41 |
Correct |
173 ms |
11896 KB |
Output is correct |
42 |
Correct |
107 ms |
11884 KB |
Output is correct |
43 |
Correct |
46 ms |
13220 KB |
Output is correct |
44 |
Correct |
835 ms |
13128 KB |
Output is correct |
45 |
Runtime error |
14 ms |
20944 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |