This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "crocodile.h"
struct DS {
    ll min1, min2;
    DS() {
        min1 = 1e18;
        min2 = 1e18;
    }
    void add(ll x) {
        if (x <= min1) {
            min2 = min1;
            min1 = x;
        } else if (x <= min2) {
            min2 = x;
        }
    }
};
bool operator<(const DS& a, const DS& b) {
    return (a.min2 != b.min2) ? (a.min2 < b.min2) : (a.min1 < b.min1);
}
typedef pair<DS, int> DATA;
int n, m;
VVPI gp;
VI exits;
int solve() {
    priority_queue<DATA, vector<DATA>, greater<DATA>> pq;
    vector<DS> dist(n);
    vector<bool> vis(n);
    for (int u : exits) {
        dist[u].min1 = dist[u].min2 = 0;
        pq.push({dist[u], u});
    }
    while (pq.size()) {
        int u = pq.top().ss;
        pq.pop();
        if (vis[u]) continue;
        vis[u] = true;
        for (auto[v, w] : gp[u]) {
            DS cur = dist[v];
            cur.add(dist[u].min2 + w);
            if (cur < dist[v]) {
                dist[v] = cur;
                pq.push({dist[v], v});
            }
        }
    }
    return dist[0].min2;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    n = N;
    m = M;
    gp = VVPI(n);
    rep(i, m) {
        int u = R[i][0];
        int v = R[i][1];
        int w = L[i];
        gp[u].pb({v, w});
        gp[v].pb({u, w});
    }
    rep(i, K) {
        exits.pb(P[i]);
    }
    return solve();
}
Compilation message (stderr)
crocodile.cpp: In function 'int solve()':
crocodile.cpp:71:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   71 |         for (auto[v, w] : gp[u]) {
      |                  ^| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |