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 "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int>>> al(100000, vector<pair<int,int>>());
vector<int> vis(100000,0);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for (int i=0; i<M; i++) {
        int u=R[i][0], v=R[i][1];
        al[u].push_back({v, L[i]});
        al[v].push_back({u, L[i]});
    }
    vector<vector<int>> time(100000, vector<int>(2, 1e9));
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> pq;
    for (int i=0; i<K; i++) {
        pq.push({0,P[i]});
        time[P[i]][0]=time[P[i]][1]=0;
    }
    while (!pq.empty()) {
        int u=pq.top().second; pq.pop();
        if (vis[u]) continue;
        vis[u]=1;
        for (auto v: al[u]) {
            if (time[u][1]+v.second<=time[v.first][0]) {
                time[v.first][1]=time[v.first][0];
                time[v.first][0]=time[u][1]+v.second;
                pq.push({time[v.first][1],v.first});
            } else {
                if (time[u][1]+v.second<=time[v.first][1]) {
                    time[v.first][1]=time[u][1]+v.second;
                    pq.push({time[v.first][1],v.first});
                }
            }
        }
    }
    return time[0][1];
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |