#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vll vector<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MAX 500005
vll vec[MAX];
ll n,pass[MAX],k;
stack<ll> q;
void init(int N, int K) {
n=N; k=K;
for(int i=0;i<k-1;i++)vec[i].push_back(i+1);
}
ll dfs(ll x,ll z){
pass[x]=z;ll r=0;
for(auto w : vec[x]){
if(pass[w]!=z)r=max(r,dfs(w,z));
else if(w==z)r=1;
}
return r;
}
int add_teleporter(int u, int v1) {
vec[u].push_back(v1);
for(int i=0;i<n;i++)pass[i]=0;
ll r=0;
for(int i=0;i<k;i++){
r=max(r,dfs(i,i));
}
return r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
13656 KB |
Output is correct |
2 |
Correct |
2 ms |
13656 KB |
Output is correct |
3 |
Correct |
9 ms |
13860 KB |
Output is correct |
4 |
Correct |
2 ms |
13656 KB |
Output is correct |
5 |
Correct |
9 ms |
13656 KB |
Output is correct |
6 |
Correct |
13 ms |
13868 KB |
Output is correct |
7 |
Correct |
9 ms |
13656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
13656 KB |
Output is correct |
2 |
Correct |
2 ms |
13656 KB |
Output is correct |
3 |
Correct |
9 ms |
13860 KB |
Output is correct |
4 |
Correct |
2 ms |
13656 KB |
Output is correct |
5 |
Correct |
9 ms |
13656 KB |
Output is correct |
6 |
Correct |
13 ms |
13868 KB |
Output is correct |
7 |
Correct |
9 ms |
13656 KB |
Output is correct |
8 |
Correct |
2 ms |
13656 KB |
Output is correct |
9 |
Correct |
2 ms |
13760 KB |
Output is correct |
10 |
Correct |
3 ms |
13656 KB |
Output is correct |
11 |
Correct |
2 ms |
13656 KB |
Output is correct |
12 |
Correct |
2 ms |
13656 KB |
Output is correct |
13 |
Correct |
2 ms |
13748 KB |
Output is correct |
14 |
Correct |
2 ms |
13656 KB |
Output is correct |
15 |
Correct |
2 ms |
13656 KB |
Output is correct |
16 |
Correct |
2 ms |
13656 KB |
Output is correct |
17 |
Correct |
5 ms |
13752 KB |
Output is correct |
18 |
Correct |
3 ms |
13656 KB |
Output is correct |
19 |
Correct |
3 ms |
13656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
13656 KB |
Output is correct |
2 |
Correct |
2 ms |
13656 KB |
Output is correct |
3 |
Correct |
9 ms |
13860 KB |
Output is correct |
4 |
Correct |
2 ms |
13656 KB |
Output is correct |
5 |
Correct |
9 ms |
13656 KB |
Output is correct |
6 |
Correct |
13 ms |
13868 KB |
Output is correct |
7 |
Correct |
9 ms |
13656 KB |
Output is correct |
8 |
Correct |
2 ms |
13656 KB |
Output is correct |
9 |
Correct |
2 ms |
13760 KB |
Output is correct |
10 |
Correct |
3 ms |
13656 KB |
Output is correct |
11 |
Correct |
2 ms |
13656 KB |
Output is correct |
12 |
Correct |
2 ms |
13656 KB |
Output is correct |
13 |
Correct |
2 ms |
13748 KB |
Output is correct |
14 |
Correct |
2 ms |
13656 KB |
Output is correct |
15 |
Correct |
2 ms |
13656 KB |
Output is correct |
16 |
Correct |
2 ms |
13656 KB |
Output is correct |
17 |
Correct |
5 ms |
13752 KB |
Output is correct |
18 |
Correct |
3 ms |
13656 KB |
Output is correct |
19 |
Correct |
3 ms |
13656 KB |
Output is correct |
20 |
Correct |
3 ms |
13656 KB |
Output is correct |
21 |
Correct |
5 ms |
13656 KB |
Output is correct |
22 |
Correct |
22 ms |
13912 KB |
Output is correct |
23 |
Correct |
3 ms |
13908 KB |
Output is correct |
24 |
Correct |
727 ms |
13904 KB |
Output is correct |
25 |
Correct |
2211 ms |
13880 KB |
Output is correct |
26 |
Correct |
1396 ms |
13920 KB |
Output is correct |
27 |
Execution timed out |
4029 ms |
14156 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
13656 KB |
Output is correct |
2 |
Correct |
2 ms |
13656 KB |
Output is correct |
3 |
Correct |
9 ms |
13860 KB |
Output is correct |
4 |
Correct |
2 ms |
13656 KB |
Output is correct |
5 |
Correct |
9 ms |
13656 KB |
Output is correct |
6 |
Correct |
13 ms |
13868 KB |
Output is correct |
7 |
Correct |
9 ms |
13656 KB |
Output is correct |
8 |
Correct |
2 ms |
13656 KB |
Output is correct |
9 |
Correct |
2 ms |
13760 KB |
Output is correct |
10 |
Correct |
3 ms |
13656 KB |
Output is correct |
11 |
Correct |
2 ms |
13656 KB |
Output is correct |
12 |
Correct |
2 ms |
13656 KB |
Output is correct |
13 |
Correct |
2 ms |
13748 KB |
Output is correct |
14 |
Correct |
2 ms |
13656 KB |
Output is correct |
15 |
Correct |
2 ms |
13656 KB |
Output is correct |
16 |
Correct |
2 ms |
13656 KB |
Output is correct |
17 |
Correct |
5 ms |
13752 KB |
Output is correct |
18 |
Correct |
3 ms |
13656 KB |
Output is correct |
19 |
Correct |
3 ms |
13656 KB |
Output is correct |
20 |
Correct |
3 ms |
13656 KB |
Output is correct |
21 |
Correct |
5 ms |
13656 KB |
Output is correct |
22 |
Correct |
22 ms |
13912 KB |
Output is correct |
23 |
Correct |
3 ms |
13908 KB |
Output is correct |
24 |
Correct |
727 ms |
13904 KB |
Output is correct |
25 |
Correct |
2211 ms |
13880 KB |
Output is correct |
26 |
Correct |
1396 ms |
13920 KB |
Output is correct |
27 |
Execution timed out |
4029 ms |
14156 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
13656 KB |
Output is correct |
2 |
Correct |
2 ms |
13656 KB |
Output is correct |
3 |
Correct |
9 ms |
13860 KB |
Output is correct |
4 |
Correct |
2 ms |
13656 KB |
Output is correct |
5 |
Correct |
9 ms |
13656 KB |
Output is correct |
6 |
Correct |
13 ms |
13868 KB |
Output is correct |
7 |
Correct |
9 ms |
13656 KB |
Output is correct |
8 |
Correct |
2 ms |
13656 KB |
Output is correct |
9 |
Correct |
2 ms |
13760 KB |
Output is correct |
10 |
Correct |
3 ms |
13656 KB |
Output is correct |
11 |
Correct |
2 ms |
13656 KB |
Output is correct |
12 |
Correct |
2 ms |
13656 KB |
Output is correct |
13 |
Correct |
2 ms |
13748 KB |
Output is correct |
14 |
Correct |
2 ms |
13656 KB |
Output is correct |
15 |
Correct |
2 ms |
13656 KB |
Output is correct |
16 |
Correct |
2 ms |
13656 KB |
Output is correct |
17 |
Correct |
5 ms |
13752 KB |
Output is correct |
18 |
Correct |
3 ms |
13656 KB |
Output is correct |
19 |
Correct |
3 ms |
13656 KB |
Output is correct |
20 |
Correct |
3 ms |
13656 KB |
Output is correct |
21 |
Correct |
5 ms |
13656 KB |
Output is correct |
22 |
Correct |
22 ms |
13912 KB |
Output is correct |
23 |
Correct |
3 ms |
13908 KB |
Output is correct |
24 |
Correct |
727 ms |
13904 KB |
Output is correct |
25 |
Correct |
2211 ms |
13880 KB |
Output is correct |
26 |
Correct |
1396 ms |
13920 KB |
Output is correct |
27 |
Execution timed out |
4029 ms |
14156 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |