#include "crocodile.h"
#include <vector>
using namespace std;
struct edge {
int x;
int y;
int w;
};
class solution {
const int kInf = 1e9 + 10;
const int n;
const int m;
const vector<edge> edges;
const int k;
const vector<int> end;
vector<vector<pair<int, int>>> g;
vector<int> dp;
int dfs(const int x, const int p) {
if (dp[x] == 0) return 0;
int mn = kInf, mn2 = kInf;
for (const auto &[y, w] : g[x]) {
if (y == p) continue;
const int cur = dfs(y, x) + w;
if (cur < mn) {
mn2 = mn;
mn = cur;
} else {
mn2 = min(mn2, cur);
}
}
return (dp[x] = mn2);
}
public:
explicit solution(const int n, const vector<edge> &edges, const vector<int> &end) : n(n), m(edges.size()), edges(edges), k(end.size()), end(end), g(n), dp(n, kInf) {
for (const auto &[x, y, w] : edges) {
g[x].emplace_back(y, w);
g[y].emplace_back(x, w);
}
for (const int x : end) dp[x] = 0;
}
int main() {
return dfs(0, -1);
return 0;
}
};
int travel_plan(const int N, const int M, const int Edges[][2], const int Cost[], const int K, const int P[]) {
vector<edge> edges(M);
for (int i = 0; i < M; i++) {
edges[i].x = Edges[i][0];
edges[i].y = Edges[i][1];
edges[i].w = Cost[i];
}
vector<int> end(K);
for (int i = 0; i < K; i++) {
end[i] = P[i];
}
solution s(N, edges, end);
return s.main();
}
Compilation message
/usr/bin/ld: /tmp/ccNQ1Rvy.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