#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template<typename T>
int len(T &a){return a.size();}
const int inf = 1e9 + 1;
int travel_plan(int n, int m, int r[][2], int L[], int K, int P[])
{
vector<vector<pair<int,int>>> g(n);
for(int i = 0; i < m; i ++){
g[r[i][0]].push_back({r[i][1], L[i]});
g[r[i][1]].push_back({r[i][0], L[i]});
}
vector<int> ex(n);
for(int i = 0; i < K; i ++) ex[P[i]] = 1;
vector<long long> dis(n);
auto dfs = [&](auto &dfs, int i, int p = -1)->ll{
if(ex[i]) return 0;
vector<ll> res;
for(auto [u, w] : g[i]){
if(u == p) continue;
res.push_back(dfs(dfs, u, i) + w);
}
if(len(res) < 2) return inf;
return res[1];
};
return dfs(dfs, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |