#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x = pow(10, 10);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
  vector<vector<pair<int,int>>> 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<pair<ll,ll>> d(N, {x, x});
  priority_queue<pair<ll,int>> pq;
  for (int i=0; i<K; i++){
    d[P[i]] = {0, 0};
    pq.push({-d[P[i]].second, P[i]});
  }
  vector<bool> seen(N, false);
  while (!pq.empty()){
    int cur = pq.top().second;
    ll dist = -pq.top().first;
    pq.pop();
    if (seen[cur]) continue;
    seen[cur] = true; 
    for (auto [next, l] : g[cur]){
      if (d[next].second > dist+l){
        d[next].second = dist+l;
        if (d[next].first > d[next].second) swap(d[next].first, d[next].second);
        if (d[next].second != x) pq.push({-d[next].second, next});
      }
    }
  }
  return d[0].second;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |