#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,sav,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);
sav=0;
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)){
// if(p[i]&&sav)continue;
ans[0]=i-1;
a[++w]=mp(i,count_common_roads(ans));
mx=max(mx,a[w].sn);
// if(p[i])sav=w;
}
}
// if(sav)mx=a[sav].sn+2-p[a[sav].fs];
for(int i=1;i<=w;++i)
if(a[i].sn==mx)p[a[i].fs]=a[i].sn+2-mx;
}
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 |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
0 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
0 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Incorrect |
18 ms |
364 KB |
WA in grader: NO |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
0 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Incorrect |
18 ms |
364 KB |
WA in grader: NO |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Incorrect |
65 ms |
2336 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Correct |
0 ms |
212 KB |
correct |
3 |
Correct |
0 ms |
212 KB |
correct |
4 |
Correct |
0 ms |
212 KB |
correct |
5 |
Correct |
0 ms |
212 KB |
correct |
6 |
Correct |
0 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
212 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
0 ms |
212 KB |
correct |
11 |
Correct |
0 ms |
212 KB |
correct |
12 |
Correct |
0 ms |
212 KB |
correct |
13 |
Correct |
0 ms |
212 KB |
correct |
14 |
Incorrect |
18 ms |
364 KB |
WA in grader: NO |
15 |
Halted |
0 ms |
0 KB |
- |