#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]});
}
priority_queue<ar<int,4>, vector<ar<int,4>>, greater<ar<int,4>>> pq;
// distance, node, parent, root
vector<ar<int,3>> dist1(n, {-1,-1,-1}), dist2(n, {-1,-1,-1});
// distance, parent, root
for (int i = 0; i < k; i++) pq.push({0,P[i],-1,P[i]});
while (!pq.empty()) {
int u = pq.top()[1], d = pq.top()[0];
int rt = pq.top()[3], par = pq.top()[2];
pq.pop();
if (dist1[u][0] == -1) {
dist1[u] = {d, par, rt};
} else if (dist2[u][0] == -1 && dist1[u][2] != rt) {
dist2[u] = {d, par, rt};
} else continue;
for (auto v : g[u]) if (dist2[v[1]][0] == -1) {
pq.push({d + v[0], v[1], u, rt});
}
}
int u = 0, res = 0;
while (dist1[u][0] != 0) {
for (auto v : g[u]) if (v[1] == dist2[u][1]) {
u = v[1]; res += v[0]; break;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2095 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2095 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2095 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |