#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
inline namespace
{
} // namespace
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vector<vector<pair<int, long>>> adj(N);
for (int i = 0; i < M; i++)
adj[R[i][0]].emplace_back(R[i][1], L[i]),
adj[R[i][1]].emplace_back(R[i][0], L[i]);
vector<array<long, 2>> dist(N, {LONG_MAX / 10, LONG_MAX / 10});
priority_queue<pair<long, int>> pq;
for (int i = 0; i < K; i++)
pq.emplace(0, P[i]), dist[P[i]] = {0, 0};
while (!pq.empty())
{
auto [d, u] = pq.top();
pq.pop();
if (-d != dist[u][1])
continue;
for (auto [v, w] : adj[u])
{
long cost = w - d;
if (cost < dist[v][0])
dist[v][1] = dist[v][0],
dist[v][0] = cost;
else if (cost < dist[v][1])
dist[v][1] = cost;
pq.emplace(-dist[v][1], v);
}
}
assert(dist[0][1] <= 1'000'000'000);
return dist[0][1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1464 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1464 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1464 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |