#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005
int N, K, good = 0, t = 1;
vector<int> in, low, scc, stk, adj[maxn];
void init(int n, int k){
N = n, K = k;
for(int i = 0; i < k - 1; ++i) adj[i].pb(i + 1);
}
void dfs(int u){
in[u] = low[u] = t++;
stk.pb(u);
for(int v:adj[u]){
if(!in[v]){
dfs(v);
low[u] = min(low[v], low[u]);
}else if(!scc[v]){
low[u] = min(in[v], low[u]);
}
}
if(low[u] >= in[u]){
int cur = stk.back(), cnt = 0, cnt2 = 0;
do{
cerr << cur << ' ';
scc[cur] = 1;
cnt += (cur < K);
cnt2++;
cur = stk.back(), stk.pop_back();
}while(stk.size() && cur != u);
if(!scc[u]){
cerr << cur << '\n';
scc[cur] = 1;
cnt += (cur < K);
cnt2++;
}
if(cnt && cnt2 > 1) good = 1;
}
}
int add_teleporter(int u, int v){
if(u == v){
if(u < K) return 1;
else return 0;
}
adj[u].pb(v);
good = 0, t = 1;
in.assign(N, 0), low.assign(N, 0), scc.assign(N, 0);
dfs(0);
if(good) return 1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7232 KB |
Output is correct |
2 |
Correct |
5 ms |
7248 KB |
Output is correct |
3 |
Correct |
73 ms |
7504 KB |
Output is correct |
4 |
Correct |
20 ms |
7248 KB |
Output is correct |
5 |
Correct |
70 ms |
7388 KB |
Output is correct |
6 |
Correct |
73 ms |
7408 KB |
Output is correct |
7 |
Correct |
81 ms |
7368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7232 KB |
Output is correct |
2 |
Correct |
5 ms |
7248 KB |
Output is correct |
3 |
Correct |
73 ms |
7504 KB |
Output is correct |
4 |
Correct |
20 ms |
7248 KB |
Output is correct |
5 |
Correct |
70 ms |
7388 KB |
Output is correct |
6 |
Correct |
73 ms |
7408 KB |
Output is correct |
7 |
Correct |
81 ms |
7368 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
9 ms |
7248 KB |
Output is correct |
12 |
Correct |
7 ms |
7248 KB |
Output is correct |
13 |
Correct |
7 ms |
7248 KB |
Output is correct |
14 |
Correct |
22 ms |
7376 KB |
Output is correct |
15 |
Correct |
34 ms |
7376 KB |
Output is correct |
16 |
Correct |
29 ms |
7364 KB |
Output is correct |
17 |
Correct |
63 ms |
7368 KB |
Output is correct |
18 |
Correct |
32 ms |
7360 KB |
Output is correct |
19 |
Correct |
35 ms |
7352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7232 KB |
Output is correct |
2 |
Correct |
5 ms |
7248 KB |
Output is correct |
3 |
Correct |
73 ms |
7504 KB |
Output is correct |
4 |
Correct |
20 ms |
7248 KB |
Output is correct |
5 |
Correct |
70 ms |
7388 KB |
Output is correct |
6 |
Correct |
73 ms |
7408 KB |
Output is correct |
7 |
Correct |
81 ms |
7368 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
9 ms |
7248 KB |
Output is correct |
12 |
Correct |
7 ms |
7248 KB |
Output is correct |
13 |
Correct |
7 ms |
7248 KB |
Output is correct |
14 |
Correct |
22 ms |
7376 KB |
Output is correct |
15 |
Correct |
34 ms |
7376 KB |
Output is correct |
16 |
Correct |
29 ms |
7364 KB |
Output is correct |
17 |
Correct |
63 ms |
7368 KB |
Output is correct |
18 |
Correct |
32 ms |
7360 KB |
Output is correct |
19 |
Correct |
35 ms |
7352 KB |
Output is correct |
20 |
Correct |
72 ms |
7392 KB |
Output is correct |
21 |
Correct |
37 ms |
7392 KB |
Output is correct |
22 |
Correct |
298 ms |
7700 KB |
Output is correct |
23 |
Correct |
37 ms |
7376 KB |
Output is correct |
24 |
Correct |
1802 ms |
10268 KB |
Output is correct |
25 |
Execution timed out |
4077 ms |
14008 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7232 KB |
Output is correct |
2 |
Correct |
5 ms |
7248 KB |
Output is correct |
3 |
Correct |
73 ms |
7504 KB |
Output is correct |
4 |
Correct |
20 ms |
7248 KB |
Output is correct |
5 |
Correct |
70 ms |
7388 KB |
Output is correct |
6 |
Correct |
73 ms |
7408 KB |
Output is correct |
7 |
Correct |
81 ms |
7368 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
9 ms |
7248 KB |
Output is correct |
12 |
Correct |
7 ms |
7248 KB |
Output is correct |
13 |
Correct |
7 ms |
7248 KB |
Output is correct |
14 |
Correct |
22 ms |
7376 KB |
Output is correct |
15 |
Correct |
34 ms |
7376 KB |
Output is correct |
16 |
Correct |
29 ms |
7364 KB |
Output is correct |
17 |
Correct |
63 ms |
7368 KB |
Output is correct |
18 |
Correct |
32 ms |
7360 KB |
Output is correct |
19 |
Correct |
35 ms |
7352 KB |
Output is correct |
20 |
Correct |
72 ms |
7392 KB |
Output is correct |
21 |
Correct |
37 ms |
7392 KB |
Output is correct |
22 |
Correct |
298 ms |
7700 KB |
Output is correct |
23 |
Correct |
37 ms |
7376 KB |
Output is correct |
24 |
Correct |
1802 ms |
10268 KB |
Output is correct |
25 |
Execution timed out |
4077 ms |
14008 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7232 KB |
Output is correct |
2 |
Correct |
5 ms |
7248 KB |
Output is correct |
3 |
Correct |
73 ms |
7504 KB |
Output is correct |
4 |
Correct |
20 ms |
7248 KB |
Output is correct |
5 |
Correct |
70 ms |
7388 KB |
Output is correct |
6 |
Correct |
73 ms |
7408 KB |
Output is correct |
7 |
Correct |
81 ms |
7368 KB |
Output is correct |
8 |
Correct |
5 ms |
7248 KB |
Output is correct |
9 |
Correct |
4 ms |
7248 KB |
Output is correct |
10 |
Correct |
4 ms |
7248 KB |
Output is correct |
11 |
Correct |
9 ms |
7248 KB |
Output is correct |
12 |
Correct |
7 ms |
7248 KB |
Output is correct |
13 |
Correct |
7 ms |
7248 KB |
Output is correct |
14 |
Correct |
22 ms |
7376 KB |
Output is correct |
15 |
Correct |
34 ms |
7376 KB |
Output is correct |
16 |
Correct |
29 ms |
7364 KB |
Output is correct |
17 |
Correct |
63 ms |
7368 KB |
Output is correct |
18 |
Correct |
32 ms |
7360 KB |
Output is correct |
19 |
Correct |
35 ms |
7352 KB |
Output is correct |
20 |
Correct |
72 ms |
7392 KB |
Output is correct |
21 |
Correct |
37 ms |
7392 KB |
Output is correct |
22 |
Correct |
298 ms |
7700 KB |
Output is correct |
23 |
Correct |
37 ms |
7376 KB |
Output is correct |
24 |
Correct |
1802 ms |
10268 KB |
Output is correct |
25 |
Execution timed out |
4077 ms |
14008 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |