#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005
int N, K, mxcnt = 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;
do{
scc[cur] = 1;
cnt += (cur < K);
cur = stk.back(), stk.pop_back();
}while(stk.size() && cur != u);
if(!scc[u]){
scc[cur] = 1;
cnt += (cur < K);
}
mxcnt = max(mxcnt, cnt);
}
}
int add_teleporter(int u, int v){
if(u >= v) return 1;
else return 0;
adj[u].pb(v);
mxcnt = 0, t = 1;
in.assign(N, 0), low.assign(N, 0), scc.assign(N, 0);
dfs(0);
if(mxcnt >= 2) return 1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7280 KB |
Output is correct |
4 |
Correct |
3 ms |
7316 KB |
Output is correct |
5 |
Correct |
4 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7320 KB |
Output is correct |
7 |
Correct |
5 ms |
7248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7280 KB |
Output is correct |
4 |
Correct |
3 ms |
7316 KB |
Output is correct |
5 |
Correct |
4 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7320 KB |
Output is correct |
7 |
Correct |
5 ms |
7248 KB |
Output is correct |
8 |
Incorrect |
4 ms |
7248 KB |
Wrong Answer[1] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7280 KB |
Output is correct |
4 |
Correct |
3 ms |
7316 KB |
Output is correct |
5 |
Correct |
4 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7320 KB |
Output is correct |
7 |
Correct |
5 ms |
7248 KB |
Output is correct |
8 |
Incorrect |
4 ms |
7248 KB |
Wrong Answer[1] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7280 KB |
Output is correct |
4 |
Correct |
3 ms |
7316 KB |
Output is correct |
5 |
Correct |
4 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7320 KB |
Output is correct |
7 |
Correct |
5 ms |
7248 KB |
Output is correct |
8 |
Incorrect |
4 ms |
7248 KB |
Wrong Answer[1] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7280 KB |
Output is correct |
4 |
Correct |
3 ms |
7316 KB |
Output is correct |
5 |
Correct |
4 ms |
7248 KB |
Output is correct |
6 |
Correct |
4 ms |
7320 KB |
Output is correct |
7 |
Correct |
5 ms |
7248 KB |
Output is correct |
8 |
Incorrect |
4 ms |
7248 KB |
Wrong Answer[1] |
9 |
Halted |
0 ms |
0 KB |
- |