#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005
int N, K, low[maxn];
vector<int> adj[maxn], rev[maxn];
void init(int n, int k){
N = n, K = k;
for(int i = 0; i < k - 1; ++i) adj[i].pb(i + 1), rev[i + 1].pb(i);
for(int i = 0; i < n; ++i) low[i] = i;
}
int add_teleporter(int u, int v){
if(u == v){
if(u < K) return 1;
else return 0;
}
adj[u].pb(v);
rev[v].pb(u);
if(low[v] >= K) return 0;
queue<int> bfs; bfs.push(v);
while(bfs.size()){
int a = bfs.front(); bfs.pop();
for(auto b:rev[a]){
if(b == low[a] && b < K) return 1;
if(low[b] > low[a]) {
low[b] = low[a];
bfs.push(b);
}
if(low[b] < b && b < K) return 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
9 ms |
14276 KB |
Output is correct |
3 |
Correct |
7 ms |
14408 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
9 ms |
14276 KB |
Output is correct |
3 |
Correct |
7 ms |
14408 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14280 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14332 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
8 ms |
14368 KB |
Output is correct |
18 |
Correct |
8 ms |
14400 KB |
Output is correct |
19 |
Correct |
8 ms |
14404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
9 ms |
14276 KB |
Output is correct |
3 |
Correct |
7 ms |
14408 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14280 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14332 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
8 ms |
14368 KB |
Output is correct |
18 |
Correct |
8 ms |
14400 KB |
Output is correct |
19 |
Correct |
8 ms |
14404 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
7 ms |
14416 KB |
Output is correct |
22 |
Correct |
7 ms |
14416 KB |
Output is correct |
23 |
Correct |
7 ms |
14416 KB |
Output is correct |
24 |
Correct |
10 ms |
14416 KB |
Output is correct |
25 |
Correct |
10 ms |
14416 KB |
Output is correct |
26 |
Correct |
9 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14440 KB |
Output is correct |
28 |
Correct |
9 ms |
14460 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
9 ms |
14276 KB |
Output is correct |
3 |
Correct |
7 ms |
14408 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14280 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14332 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
8 ms |
14368 KB |
Output is correct |
18 |
Correct |
8 ms |
14400 KB |
Output is correct |
19 |
Correct |
8 ms |
14404 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
7 ms |
14416 KB |
Output is correct |
22 |
Correct |
7 ms |
14416 KB |
Output is correct |
23 |
Correct |
7 ms |
14416 KB |
Output is correct |
24 |
Correct |
10 ms |
14416 KB |
Output is correct |
25 |
Correct |
10 ms |
14416 KB |
Output is correct |
26 |
Correct |
9 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14440 KB |
Output is correct |
28 |
Correct |
9 ms |
14460 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
30 |
Correct |
26 ms |
15620 KB |
Output is correct |
31 |
Correct |
13 ms |
14928 KB |
Output is correct |
32 |
Correct |
27 ms |
16288 KB |
Output is correct |
33 |
Correct |
24 ms |
16280 KB |
Output is correct |
34 |
Correct |
545 ms |
16380 KB |
Output is correct |
35 |
Correct |
205 ms |
16456 KB |
Output is correct |
36 |
Correct |
39 ms |
16332 KB |
Output is correct |
37 |
Correct |
28 ms |
16368 KB |
Output is correct |
38 |
Correct |
32 ms |
16072 KB |
Output is correct |
39 |
Correct |
34 ms |
16084 KB |
Output is correct |
40 |
Correct |
477 ms |
16576 KB |
Output is correct |
41 |
Correct |
108 ms |
16160 KB |
Output is correct |
42 |
Correct |
79 ms |
16140 KB |
Output is correct |
43 |
Correct |
40 ms |
16504 KB |
Output is correct |
44 |
Correct |
498 ms |
16532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
9 ms |
14276 KB |
Output is correct |
3 |
Correct |
7 ms |
14408 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14280 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
7 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14332 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
8 ms |
14368 KB |
Output is correct |
18 |
Correct |
8 ms |
14400 KB |
Output is correct |
19 |
Correct |
8 ms |
14404 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
7 ms |
14416 KB |
Output is correct |
22 |
Correct |
7 ms |
14416 KB |
Output is correct |
23 |
Correct |
7 ms |
14416 KB |
Output is correct |
24 |
Correct |
10 ms |
14416 KB |
Output is correct |
25 |
Correct |
10 ms |
14416 KB |
Output is correct |
26 |
Correct |
9 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14440 KB |
Output is correct |
28 |
Correct |
9 ms |
14460 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
30 |
Correct |
26 ms |
15620 KB |
Output is correct |
31 |
Correct |
13 ms |
14928 KB |
Output is correct |
32 |
Correct |
27 ms |
16288 KB |
Output is correct |
33 |
Correct |
24 ms |
16280 KB |
Output is correct |
34 |
Correct |
545 ms |
16380 KB |
Output is correct |
35 |
Correct |
205 ms |
16456 KB |
Output is correct |
36 |
Correct |
39 ms |
16332 KB |
Output is correct |
37 |
Correct |
28 ms |
16368 KB |
Output is correct |
38 |
Correct |
32 ms |
16072 KB |
Output is correct |
39 |
Correct |
34 ms |
16084 KB |
Output is correct |
40 |
Correct |
477 ms |
16576 KB |
Output is correct |
41 |
Correct |
108 ms |
16160 KB |
Output is correct |
42 |
Correct |
79 ms |
16140 KB |
Output is correct |
43 |
Correct |
40 ms |
16504 KB |
Output is correct |
44 |
Correct |
498 ms |
16532 KB |
Output is correct |
45 |
Correct |
265 ms |
26808 KB |
Output is correct |
46 |
Correct |
13 ms |
16052 KB |
Output is correct |
47 |
Correct |
15 ms |
16080 KB |
Output is correct |
48 |
Correct |
315 ms |
34292 KB |
Output is correct |
49 |
Correct |
272 ms |
34248 KB |
Output is correct |
50 |
Execution timed out |
4035 ms |
34332 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |