#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
    vector<pll> g[n];
    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] });
    }
    vector<ll> D(n, 1e18), b1(n, 1e18), b2(n, 1e18), vis(n);
    priority_queue<pll, vector<pll>, greater<pll> > pq;
    for(int i=0; i<k; i++) {
        D[P[i]] = b1[P[i]] = b2[P[i]] = 0;
        pq.push({ 0, P[i] });
    }
    while(!pq.empty()) {
        auto [d, u] = pq.top(); pq.pop();
        if(vis[u]) continue;
        vis[u] = 1;
        D[u] = d;
        for(auto [v, w] : g[u]) {
            if(d + w < b2[v] && !vis[v]) {
                if(d + w <= b1[v]) {
                    b2[v] = b1[v];
                    b1[v] = d + w;
                } else b2[v] = d + w;
                pq.push({ b2[v], v });
            }
        }
    }
    return D[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... |