#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
#define INF 1e+18
#define pb push_back
using namespace std;
struct edge{ ll to,cost; };
typedef pair<int,int> P;
ll n,m,d1[100010],d2[100010];
vector<edge> G[100010];
int travel_plan(int N, int M, int R[][2], int L[], int K, int Q[]){
n = N,m = M;
for(int i = 0;i < n;i++){
d1[i] = INF;
d2[i] = INF;
}
for(int i = 0;i < m;i++){
G[R[i][0]].pb({R[i][1],L[i]});
G[R[i][1]].pb({R[i][0],L[i]});
}
priority_queue<P,vector<P>,greater<P>> que;
for(int i = 0;i < K;i++){
d1[Q[i]] = 0;
d2[Q[i]] = 0;
que.push(P(0,Q[i]));
}
while(!que.empty()){
P p = que.top();que.pop();
ll v = p.second;
for(edge e : G[v]){
ll cost = d2[v] + e.cost;
if(d1[e.to] > cost) swap(d1[e.to],cost);
if(d2[e.to] > cost){
d2[e.to] = cost;
que.push(P(d2[e.to],e.to));
}
}
}
return d2[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Incorrect |
7 ms |
2688 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Incorrect |
7 ms |
2688 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Incorrect |
7 ms |
2688 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |