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>
#define ll long long
using namespace std;
const ll INF = 1e18;
struct Comp {
    int nod;
    ll val;
    bool operator <(const Comp &other) const {
        return val > other.val;
    }
};
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]});
    }
    priority_queue <Comp> pq;
    vector <ll> dst(N, INF);
    vector <int> cnt(N);
    for(int i = 0; i < K; i++) {
        dst[P[i]] = 0;
        pq.push({P[i], 0});
        cnt[P[i]] = 1;
    }
    while(pq.size()) {
        auto cur = pq.top();
        pq.pop();
        if(cnt[cur.nod] == 2) {
            continue;
        }
        cnt[cur.nod]++;
        dst[cur.nod] = cur.val;
        if(cnt[cur.nod] == 2) {
            for(auto it : g[cur.nod]) {
                pq.push({it.first, cur.val + it.second});
            }
        }
    }
    return (int) dst[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... |