This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int INF = 1e9 + 5;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
vector<vector<pair<int, int>>> adj(N);
for(int i = 0; i < M; i++){
adj[R[i][0]].push_back({R[i][1], L[i]});
adj[R[i][1]].push_back({R[i][0], L[i]});
}
priority_queue<array<int64_t, 2>, vector<array<int64_t, 2>>, greater<array<int64_t, 2>>> pq;
vector<array<int64_t, 2>> d(N, {INF, INF});
for(int i = 0; i < K; i++){
d[P[i]] = {0, 0};
pq.push({0, int64_t(P[i])});
}
while(!pq.empty()){
auto[dv, node] = pq.top();
pq.pop();
if(dv > d[node][1]) continue;
for(auto& [v, l] : adj[node]){
int64_t nx = dv + int64_t(l);
if(d[v][1] < nx)
continue;
d[v][1] = nx;
if(d[v][1] < d[v][0]) swap(d[v][1], d[v][0]);
pq.push({nx, v});
}
}
return d[0][0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |