#include "simurgh.h"
#include <cstdio>
#include <cassert>
#include <vector>
#include <cstdlib>
#include <string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 1001000
#define mp make_pair
#define fs first
#define sn second
int n,m,x,y,mx,w,xx,yy,fa[N],p[N];
pair<int,int>a[N],l[N];
vector<int>ans;
int find(int x)
{
return (fa[x]==x?x:fa[x]=find(fa[x]));
}
std::vector<int> find_roads(int nn, std::vector<int> u, std::vector<int> v) {
n=nn;
m=u.size();
for(int i=1;i<=m;++i)
l[i]=mp(u[i-1]+1,v[i-1]+1);
for(int k=1;k<=m;++k){
if(p[k])continue;
for(int i=1;i<=n;++i)
fa[i]=i;
ans.clear();
ans.push_back(0);
xx=l[k].fs;
yy=l[k].sn;
// printf("%d:--------------\n",k);
for(int i=1;i<=m;++i){
x=find(l[i].fs);
y=find(l[i].sn);
// printf("%d %d\n",x,y);
xx=find(xx);
yy=find(yy);
if(x!=y){
if((x==xx&&y==yy)||(x==yy&&y==xx))continue;
fa[x]=y;
ans.push_back(i-1);
}
}
mx=0;
w=0;
xx=find(xx);
yy=find(yy);
for(int i=1;i<=m;++i){
x=find(l[i].fs);
y=find(l[i].sn);
if((x==xx&&y==yy)||(x==yy&&y==xx)){
ans[0]=i-1;
a[++w]=mp(i,count_common_roads(ans));
mx=max(mx,a[w].sn);
}
}
for(int i=1;i<=w;++i)
if(a[i].sn==mx)p[a[i].fs]=2;
else p[a[i].fs]=1;
}
ans.clear();
for(int i=1;i<=m;++i)
if(p[i]==2)ans.push_back(i-1);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
1 ms |
308 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
1 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
312 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
304 KB |
correct |
12 |
Correct |
1 ms |
308 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
1 ms |
308 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
1 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
312 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
304 KB |
correct |
12 |
Correct |
1 ms |
308 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
14 |
Correct |
6 ms |
312 KB |
correct |
15 |
Correct |
6 ms |
340 KB |
correct |
16 |
Correct |
5 ms |
312 KB |
correct |
17 |
Correct |
4 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
340 KB |
correct |
19 |
Correct |
5 ms |
340 KB |
correct |
20 |
Correct |
5 ms |
312 KB |
correct |
21 |
Correct |
4 ms |
340 KB |
correct |
22 |
Correct |
3 ms |
340 KB |
correct |
23 |
Correct |
3 ms |
340 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
340 KB |
correct |
27 |
Correct |
3 ms |
304 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
4 ms |
340 KB |
correct |
31 |
Correct |
3 ms |
340 KB |
correct |
32 |
Correct |
4 ms |
340 KB |
correct |
33 |
Correct |
3 ms |
340 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
1 ms |
308 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
1 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
312 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
304 KB |
correct |
12 |
Correct |
1 ms |
308 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
14 |
Correct |
6 ms |
312 KB |
correct |
15 |
Correct |
6 ms |
340 KB |
correct |
16 |
Correct |
5 ms |
312 KB |
correct |
17 |
Correct |
4 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
340 KB |
correct |
19 |
Correct |
5 ms |
340 KB |
correct |
20 |
Correct |
5 ms |
312 KB |
correct |
21 |
Correct |
4 ms |
340 KB |
correct |
22 |
Correct |
3 ms |
340 KB |
correct |
23 |
Correct |
3 ms |
340 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
340 KB |
correct |
27 |
Correct |
3 ms |
304 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
4 ms |
340 KB |
correct |
31 |
Correct |
3 ms |
340 KB |
correct |
32 |
Correct |
4 ms |
340 KB |
correct |
33 |
Correct |
3 ms |
340 KB |
correct |
34 |
Incorrect |
75 ms |
1352 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Incorrect |
62 ms |
3128 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
correct |
2 |
Correct |
1 ms |
212 KB |
correct |
3 |
Correct |
1 ms |
308 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
1 ms |
212 KB |
correct |
7 |
Correct |
1 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
312 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
304 KB |
correct |
12 |
Correct |
1 ms |
308 KB |
correct |
13 |
Correct |
0 ms |
340 KB |
correct |
14 |
Correct |
6 ms |
312 KB |
correct |
15 |
Correct |
6 ms |
340 KB |
correct |
16 |
Correct |
5 ms |
312 KB |
correct |
17 |
Correct |
4 ms |
340 KB |
correct |
18 |
Correct |
2 ms |
340 KB |
correct |
19 |
Correct |
5 ms |
340 KB |
correct |
20 |
Correct |
5 ms |
312 KB |
correct |
21 |
Correct |
4 ms |
340 KB |
correct |
22 |
Correct |
3 ms |
340 KB |
correct |
23 |
Correct |
3 ms |
340 KB |
correct |
24 |
Correct |
2 ms |
340 KB |
correct |
25 |
Correct |
1 ms |
340 KB |
correct |
26 |
Correct |
2 ms |
340 KB |
correct |
27 |
Correct |
3 ms |
304 KB |
correct |
28 |
Correct |
1 ms |
340 KB |
correct |
29 |
Correct |
1 ms |
212 KB |
correct |
30 |
Correct |
4 ms |
340 KB |
correct |
31 |
Correct |
3 ms |
340 KB |
correct |
32 |
Correct |
4 ms |
340 KB |
correct |
33 |
Correct |
3 ms |
340 KB |
correct |
34 |
Incorrect |
75 ms |
1352 KB |
WA in grader: NO |
35 |
Halted |
0 ms |
0 KB |
- |