#include<bits/stdc++.h>
using namespace std;
const int maxn=300000+10,maxk=1000+10;
short int fk=0,fn=0,f=0;
vector<short int>adj[maxn],revadj[maxn];
char vis[maxk][maxn],revvis[maxk][maxn];
void dfs(int u,int v){
if(revvis[v][u]==1){
f=1;
}
vis[v][u]=1;
for(auto x:adj[u]){
if(vis[v][x]==0){
dfs(x,v);
}
}
}
void revdfs(int u,int v){
if(vis[v][u]==1){
f=1;
}
revvis[v][u]=1;
for(auto x:revadj[u]){
if(revvis[v][x]==0){
revdfs(x,v);
}
}
}
void con(int a,int b){
if(a==b&&a<fk){
f=1;
return;
}
adj[a].push_back(b);
revadj[b].push_back(a);
for(int i=0;i<fk;i++){
if(vis[i][a]==1&&vis[i][b]==0){
dfs(b,i);
}
if(revvis[i][a]==0&&revvis[i][b]==1){
revdfs(a,i);
}
}
}
void init(int n, int k) {
for(int i=0;i<k;i++){
vis[i][i]=revvis[i][i]=1;
}
fk=k;
fn=n;
for(int i=0;i<k-1;i++){
con(i,i+1);
}
}
int add_teleporter(int u, int v) {
con(u,v);
if(f){
return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14404 KB |
Output is correct |
3 |
Correct |
8 ms |
15312 KB |
Output is correct |
4 |
Correct |
8 ms |
14800 KB |
Output is correct |
5 |
Correct |
9 ms |
15312 KB |
Output is correct |
6 |
Correct |
8 ms |
15312 KB |
Output is correct |
7 |
Correct |
9 ms |
15312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14404 KB |
Output is correct |
3 |
Correct |
8 ms |
15312 KB |
Output is correct |
4 |
Correct |
8 ms |
14800 KB |
Output is correct |
5 |
Correct |
9 ms |
15312 KB |
Output is correct |
6 |
Correct |
8 ms |
15312 KB |
Output is correct |
7 |
Correct |
9 ms |
15312 KB |
Output is correct |
8 |
Correct |
8 ms |
14416 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14416 KB |
Output is correct |
12 |
Correct |
8 ms |
14416 KB |
Output is correct |
13 |
Correct |
8 ms |
14400 KB |
Output is correct |
14 |
Correct |
10 ms |
14800 KB |
Output is correct |
15 |
Correct |
10 ms |
14636 KB |
Output is correct |
16 |
Correct |
10 ms |
14464 KB |
Output is correct |
17 |
Correct |
9 ms |
14864 KB |
Output is correct |
18 |
Correct |
9 ms |
14800 KB |
Output is correct |
19 |
Correct |
9 ms |
14800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14404 KB |
Output is correct |
3 |
Correct |
8 ms |
15312 KB |
Output is correct |
4 |
Correct |
8 ms |
14800 KB |
Output is correct |
5 |
Correct |
9 ms |
15312 KB |
Output is correct |
6 |
Correct |
8 ms |
15312 KB |
Output is correct |
7 |
Correct |
9 ms |
15312 KB |
Output is correct |
8 |
Correct |
8 ms |
14416 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14416 KB |
Output is correct |
12 |
Correct |
8 ms |
14416 KB |
Output is correct |
13 |
Correct |
8 ms |
14400 KB |
Output is correct |
14 |
Correct |
10 ms |
14800 KB |
Output is correct |
15 |
Correct |
10 ms |
14636 KB |
Output is correct |
16 |
Correct |
10 ms |
14464 KB |
Output is correct |
17 |
Correct |
9 ms |
14864 KB |
Output is correct |
18 |
Correct |
9 ms |
14800 KB |
Output is correct |
19 |
Correct |
9 ms |
14800 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
9 ms |
15440 KB |
Output is correct |
22 |
Correct |
10 ms |
15440 KB |
Output is correct |
23 |
Correct |
9 ms |
14528 KB |
Output is correct |
24 |
Correct |
20 ms |
19532 KB |
Output is correct |
25 |
Correct |
15 ms |
17104 KB |
Output is correct |
26 |
Correct |
14 ms |
15532 KB |
Output is correct |
27 |
Correct |
30 ms |
19640 KB |
Output is correct |
28 |
Correct |
22 ms |
19640 KB |
Output is correct |
29 |
Correct |
25 ms |
19636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14404 KB |
Output is correct |
3 |
Correct |
8 ms |
15312 KB |
Output is correct |
4 |
Correct |
8 ms |
14800 KB |
Output is correct |
5 |
Correct |
9 ms |
15312 KB |
Output is correct |
6 |
Correct |
8 ms |
15312 KB |
Output is correct |
7 |
Correct |
9 ms |
15312 KB |
Output is correct |
8 |
Correct |
8 ms |
14416 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14416 KB |
Output is correct |
12 |
Correct |
8 ms |
14416 KB |
Output is correct |
13 |
Correct |
8 ms |
14400 KB |
Output is correct |
14 |
Correct |
10 ms |
14800 KB |
Output is correct |
15 |
Correct |
10 ms |
14636 KB |
Output is correct |
16 |
Correct |
10 ms |
14464 KB |
Output is correct |
17 |
Correct |
9 ms |
14864 KB |
Output is correct |
18 |
Correct |
9 ms |
14800 KB |
Output is correct |
19 |
Correct |
9 ms |
14800 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
9 ms |
15440 KB |
Output is correct |
22 |
Correct |
10 ms |
15440 KB |
Output is correct |
23 |
Correct |
9 ms |
14528 KB |
Output is correct |
24 |
Correct |
20 ms |
19532 KB |
Output is correct |
25 |
Correct |
15 ms |
17104 KB |
Output is correct |
26 |
Correct |
14 ms |
15532 KB |
Output is correct |
27 |
Correct |
30 ms |
19640 KB |
Output is correct |
28 |
Correct |
22 ms |
19640 KB |
Output is correct |
29 |
Correct |
25 ms |
19636 KB |
Output is correct |
30 |
Correct |
96 ms |
21992 KB |
Output is correct |
31 |
Correct |
303 ms |
79688 KB |
Output is correct |
32 |
Correct |
132 ms |
21340 KB |
Output is correct |
33 |
Correct |
32 ms |
16876 KB |
Output is correct |
34 |
Correct |
1955 ms |
56204 KB |
Output is correct |
35 |
Correct |
2162 ms |
84056 KB |
Output is correct |
36 |
Correct |
167 ms |
22720 KB |
Output is correct |
37 |
Correct |
2584 ms |
77308 KB |
Output is correct |
38 |
Correct |
2270 ms |
77844 KB |
Output is correct |
39 |
Correct |
2403 ms |
78676 KB |
Output is correct |
40 |
Correct |
2549 ms |
84292 KB |
Output is correct |
41 |
Correct |
2093 ms |
83624 KB |
Output is correct |
42 |
Correct |
2001 ms |
83624 KB |
Output is correct |
43 |
Correct |
3501 ms |
85400 KB |
Output is correct |
44 |
Correct |
2440 ms |
77424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14404 KB |
Output is correct |
3 |
Correct |
8 ms |
15312 KB |
Output is correct |
4 |
Correct |
8 ms |
14800 KB |
Output is correct |
5 |
Correct |
9 ms |
15312 KB |
Output is correct |
6 |
Correct |
8 ms |
15312 KB |
Output is correct |
7 |
Correct |
9 ms |
15312 KB |
Output is correct |
8 |
Correct |
8 ms |
14416 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14416 KB |
Output is correct |
12 |
Correct |
8 ms |
14416 KB |
Output is correct |
13 |
Correct |
8 ms |
14400 KB |
Output is correct |
14 |
Correct |
10 ms |
14800 KB |
Output is correct |
15 |
Correct |
10 ms |
14636 KB |
Output is correct |
16 |
Correct |
10 ms |
14464 KB |
Output is correct |
17 |
Correct |
9 ms |
14864 KB |
Output is correct |
18 |
Correct |
9 ms |
14800 KB |
Output is correct |
19 |
Correct |
9 ms |
14800 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
9 ms |
15440 KB |
Output is correct |
22 |
Correct |
10 ms |
15440 KB |
Output is correct |
23 |
Correct |
9 ms |
14528 KB |
Output is correct |
24 |
Correct |
20 ms |
19532 KB |
Output is correct |
25 |
Correct |
15 ms |
17104 KB |
Output is correct |
26 |
Correct |
14 ms |
15532 KB |
Output is correct |
27 |
Correct |
30 ms |
19640 KB |
Output is correct |
28 |
Correct |
22 ms |
19640 KB |
Output is correct |
29 |
Correct |
25 ms |
19636 KB |
Output is correct |
30 |
Correct |
96 ms |
21992 KB |
Output is correct |
31 |
Correct |
303 ms |
79688 KB |
Output is correct |
32 |
Correct |
132 ms |
21340 KB |
Output is correct |
33 |
Correct |
32 ms |
16876 KB |
Output is correct |
34 |
Correct |
1955 ms |
56204 KB |
Output is correct |
35 |
Correct |
2162 ms |
84056 KB |
Output is correct |
36 |
Correct |
167 ms |
22720 KB |
Output is correct |
37 |
Correct |
2584 ms |
77308 KB |
Output is correct |
38 |
Correct |
2270 ms |
77844 KB |
Output is correct |
39 |
Correct |
2403 ms |
78676 KB |
Output is correct |
40 |
Correct |
2549 ms |
84292 KB |
Output is correct |
41 |
Correct |
2093 ms |
83624 KB |
Output is correct |
42 |
Correct |
2001 ms |
83624 KB |
Output is correct |
43 |
Correct |
3501 ms |
85400 KB |
Output is correct |
44 |
Correct |
2440 ms |
77424 KB |
Output is correct |
45 |
Runtime error |
271 ms |
38804 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |