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 "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<int>>> edg;
map<int, int> mp;
vector<int> vis;
int dfs(int idx) {
vector<int> v;
for (auto &i : edg[idx]) {
if (!vis[i[0]]) {
vis[i[0]] = 1;
int e = i[1];
if (!mp[i[0]]) {
e += dfs(i[0]);
}
v.push_back(e);
}
}
sort(v.begin(), v.end());
return v[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
edg.resize(N);
vis.resize(N);
for (int i = 0; i < M; i++) {
edg[R[i][0]].push_back({R[i][1], L[i]});
edg[R[i][1]].push_back({R[i][0], L[i]});
}
for (int i = 0; i < K ; i++) {
mp[P[i]]++;
}
vis[0] = 1;
return dfs(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |