This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef pair<int,int>pii;
vector<pii>adj[100005];
int dfs(int index, int par){
vector<int>v;
for(auto it:adj[index]){
if(it.first==par) continue;
v.push_back(dfs(it.first,index)+it.second);
}
sort(v.begin(),v.end());
if(v.size()>=2){
return v[1];
}
else return 0;
}
int travel_plan(int n, int m, int r[][2], int w[], int k, int p[]){
for(int x=0;x<m;x++){
adj[r[x][0]].push_back({r[x][1],w[x]});
adj[r[x][1]].push_back({r[x][0],w[x]});
}
return dfs(0,-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |