#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  vector<vector<pair<long long, long long>>> ed(N);
  for(long long i = 0; i < M; ++i){
    ed[R[i][0]].push_back({R[i][1], L[i]});
    ed[R[i][1]].push_back({R[i][0], L[i]});
  }
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> pq;
  vector<pair<long long, long long>> paths(N, make_pair(1e15, 1e15));
  long long dist[N];
  for(long long i = 0; i < N; ++i){
    dist[i] = 1e15;
  }
  for(int i = 0; i < K; ++i){
    dist[P[i]] = 0;
    pq.push({0, P[i]});
  }
  while(!pq.empty()){
    long long no = pq.top().second;
    long long dis = pq.top().first;
    pq.pop();
    if(dist[no] < dis){
      continue;
    }
    //cout << no << " " << dis << endl;
    dist[no] = dis;
    for(auto e:ed[no]){
      if(dist[e.first] != 1e15){
        continue;
      }
      if(dis + e.second > paths[e.first].second){
        continue;
      }
      paths[e.first].second = min(paths[e.first].second, dis + e.second);
      if(paths[e.first].first > paths[e.first].second){
        swap(paths[e.first].first, paths[e.first].second);
      }
      if(paths[e.first].second != -1){
        pq.push({paths[e.first].second, e.first});
      }
    }
  }
  return dist[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... |