#include <bits/stdc++.h>
#include "simurgh.h"
#define f first
#define s second
#define pb push_back
#define mx 250003
#define ALL(x) x.begin(),x.end()
using namespace std;
int di[mx],M,idx,brp[505][505];
bool sudah[mx];
int P[mx];
vector<pair<int,int>>cycle;
vector<int> r;
vector<int>g[mx];
void dfs(int now,int par=0){
sudah[now]=true;
for(auto i:g[now]){
if(i==par)
continue;
if(!sudah[i]){
P[now]=i;
di[brp[now][i]]=idx++;
r.pb(brp[now][i]);
dfs(i,now);
}
else{
cycle.pb({now,i});
}
}
}
vector<int> find_roads(int N, vector<int> u, vector<int> v) {
M=u.size();
for(int i=0;i<M;i++){
g[u[i]+1].pb(v[i]+1);
g[v[i]+1].pb(u[i]+1);
brp[u[i]+1][v[i]+1]=i;
brp[v[i]+1][u[i]+1]=i;
}
memset(di,-1,sizeof di);
dfs(1,0);
vector<int>satu(N-1);
int maks=count_common_roads(r);
for(auto i:cycle){
int dari=i.f,ke=i.s;
int besar=0;
while(dari!=ke){
if(di[brp[dari][P[dari]]]!=-1){
int tmp=brp[dari][P[dari]];
r[di[tmp]]=brp[i.f][i.s];
int sem=count_common_roads(r);
if(sem>besar){
satu=r;
besar=sem;
}
r[di[tmp]]=brp[dari][P[dari]];
}
dari=P[dari];
}
if(besar>maks){
r=satu;
memset(di,-1,sizeof di);
for(int i=0;i<N-1;i++){
di[r[i]]=i;
}
}
}
return r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7160 KB |
WA in grader: NO |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7160 KB |
WA in grader: NO |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7160 KB |
WA in grader: NO |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7160 KB |
correct |
2 |
Incorrect |
9 ms |
7204 KB |
WA in grader: NO |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7160 KB |
WA in grader: NO |
2 |
Halted |
0 ms |
0 KB |
- |