//Nguyen Huu Hoang Minh
#include <bits/stdc++.h>
//#include "crocodile.h"
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define reset(x) memset(x, 0,sizeof(x))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define remain(x) if (x > MOD) x -= MOD
#define ii pair<int, int>
#define iiii pair< ii , ii >
#define viiii vector< iiii >
#define vi vector<int>
#define vii vector< ii >
#define bit(x, i) (((x) >> (i)) & 1)
#define Task "test"
#define int long long
using namespace std;
typedef long double ld;
const int inf = 1e10;
const int minf = -1e10;
vector<ii> g[100005];
int dp[100005];
bool is[100005];
void dfs(int u, int pre){
vector<int> ans;
if (is[u]) dp[u] = 0;
else dp[u] = inf;
for(auto i : g[u]){
int v = i.fi;
int uv = i.se;
if (v!=pre){
dfs(v,u);
if (dp[v]!=inf) ans.pb(dp[v]+uv);
}
}
sort(all(ans));
if (ans.size()>1) dp[u] = ans[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
for(int i=0; i<M; i++){
int u = R[i][0];
int v = R[i][1];
int z = L[i];
g[u].pb(ii(v,z));
g[v].pb(ii(u,z));
}
for(int i=0; i<K; i++){
is[P[i]] = 1;
}
dfs(0,0);
return dp[0];
}
signed main(){
int r[4][2];
int l[4];
int p[3];
r[1][0]=0; r[1][1] =1; r[0][0]=0; r[0][1]=2; r[2][0]=3; r[2][1]=2; r[3][0]=2; r[3][1]=4;
l[1]=2; l[0]=3; l[2]=1; l[3]=4;
p[0]=1; p[1]=3; p[2] = 4;
cout << travel_plan(5,4,r,l,3,p);
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccPvLMRP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccfc60vR.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccPvLMRP.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status