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;
vector <pair<int, int>> v[100010];
set <int> wn;
int dfs(int pos, int prec) {
if (wn.find(pos) != wn.end()) return 0;
vector < int > s;
for (auto k: v[pos]) {
if (k.first == prec) continue;
s.push_back(dfs(k.first, pos) + k.second);
}
sort(s.begin(), s.end());
s.push_back(int(1e12));
s.push_back(int(1e12));
return s[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
for (int i = 0; i < M; i++) {
v[R[i][0]].push_back({
R[i][1],
L[i]
});
v[R[i][1]].push_back({
R[i][0],
L[i]
});
}
for (int i = 0; i < K; i++) wn.insert(P[i]);
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... |