#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
using ll = long long;
int travel_plan(int n, int m, int r[][2], int L[], int k, int p[]){
vector<int> lst(n);
priority_queue<pair<ll,int>> pq;
vector<vector<ll>> dist(n);
for(int i = 0; i < k; i++){
pq.emplace(0, p[i]);
lst[p[i]] = 1;
dist[p[i]].push_back(0);
}
vector<vector<pair<int,int>>> g(n);
for(int i = 0; i < m; i++){
g[r[i][0]].emplace_back(r[i][1], L[i]);
g[r[i][1]].emplace_back(r[i][0], L[i]);
}
while(pq.size()){
auto [d, v] = pq.top(); pq.pop();
if(v == 0) return -d;
for(auto [u, w]: g[v]){
if(dist[u].empty()){
dist[u].push_back(-d + w);
}else if(dist[u].size() == 1){
dist[u].push_back(-d + w);
sort(dist[u].begin(), dist[u].end());
pq.emplace(-dist[u][1], u);
}else{
if(-d + w < dist[u][1]){
dist[u].push_back(-d + w);
sort(dist[u].begin(), dist[u].end());
dist[u].pop_back();
pq.emplace(-dist[u][1], u);
}
}
}
}
assert(false);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |