#include <iostream>
#include <queue>
#include <vector>
#include <functional>
#include <utility>
#include <climits>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
int xd, b, w;
bool vis[100005];
pair<int, int> dist[100005];
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
vector<vector<pair<int, int>>> g(n);
for(int i=0; i<n; i++) {
dist[i] = {1000000001, 1000000001};
}
for(int i=0; i<m; i++) {
g[r[i][0]].push_back({r[i][1], l[i]});
g[r[i][1]].push_back({r[i][0], l[i]});
}
for(int i=0; i<k; i++) {
dist[p[i]] = {0, 0};
pq.push({0, p[i]});
}
while(!pq.empty()) {
xd = pq.top().second;
pq.pop();
if(vis[xd]) continue;
vis[xd] = true;
for(auto z : g[xd]) {
b = z.first;
w = z.second;
if(dist[b].first > dist[b].second) {
swap(dist[b].first, dist[b].second);
}
if(max(dist[xd].first, dist[xd].second)+w < dist[b].second) {
dist[b].second = min(max(dist[xd].first, dist[xd].second)+w, 1000000001);
if(dist[b].second < 1000000001) {
pq.push({dist[b].second, b});
}
}
}
}
return max(dist[0].first, dist[0].second);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4544 KB |
Output is correct |
2 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4544 KB |
Output is correct |
2 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4544 KB |
Output is correct |
2 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |