#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000 + 5;
bool is_exit[MAX_N];
vector<pair<int, long long>> g[MAX_N];
long long solve(int u, int p) {
if (is_exit[u]) {
assert(g[u].size() == 1);
return 0;
}
long long ret = 0;
for (pair<int, long long> edge : g[u]) {
if (edge.first == p) continue;
ret = max(ret, solve(edge.first, u) + edge.second);
}
return ret;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
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] });
}
for (int i=0 ; i<K ; i++) {
is_exit[P[i]] = true;
}
return solve(0, -1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |