#include "crocodile.h"
#include <algorithm>
#include <climits>
#include <vector>
#include <set>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
#define f first
#define s second
set<pair<ll, ll> > a[100000]; priority_queue<pair<ll, ll> > b; ll t, mn, i, c[100000];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
while (M--) a[R[M][0]].insert(make_pair(L[M], R[M][1])), a[R[M][1]].insert(make_pair(L[M], R[M][0]));
for (i = 1; i < N; i++) c[i] = LONG_LONG_MAX; b.push(make_pair(0, 0));
while (!b.empty()) {
t = b.top().s; b.pop();
for (auto i = ++a[t].begin(); i != a[t].end(); i++) if (c[t] + (*i).f < c[(*i).s])
c[(*i).s] = c[t] + (*i).f, b.push(make_pair(c[(*i).s], (*i).s));
}mn = c[P[--K]];
while (K--) mn = min(mn, c[P[K]]);
return mn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |