#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
vector<pair<int, int>> adj[N];
for(int i = 0; i < M; i ++){
adj[R[i][0]].push_back({R[i][1], L[i]});
adj[R[i][1]].push_back({R[i][0], L[i]});
}
int T[N];
for(int i = 0; i < N; i ++) T[i] = 0;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
for(int i = 0; i < K; i ++){
pq.push({0, P[i]});
T[P[i]] = 2;
}
while(!pq.empty()){
int u = pq.top().second;
int du = pq.top().first;
pq.pop();
T[u] ++ ;
if(T[u] == 2){
if(!u) return du;
for(auto [v, w] : adj[u]){
if(T[u] >= 2) continue ;
pq.push({du + w, v});
}
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |