#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ar array
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
vector<ar<int,2>> g[n];
for (int i = 0; i < m; i++) {
g[R[i][0]].push_back({L[i], R[i][1]});
g[R[i][1]].push_back({L[i], R[i][0]});
}
vector<bool> isP(n, 0);
for (int i = 0; i < k; i++) isP[P[i]] = 1;
priority_queue<ar<int,2>, vector<ar<int,2>>, greater<ar<int,2>>> pq;
for (int i = 0; i < n; i++) {
vector<int> wt;
for (auto j : g[i]) {
if (isP[j[1]]) wt.push_back(j[0]);
}
sort(wt.begin(), wt.end());
if (wt.size() > 1) {
pq.push({wt[1], i});
}
}
if (isP[0]) return 0;
vector<int> dist(n, -1);
while (!pq.empty()) {
int u = pq.top()[1], d = pq.top()[0];
pq.pop();
if (dist[u] != -1) continue;
dist[u] = d;
for (auto v : g[u]) if (dist[v[1]] == -1) {
pq.push({d+v[0], v[1]});
}
}
assert(dist[0] != -1);
return dist[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |