#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector<pii> graph[N];
for(int i=0; i<M; i++) {
graph[R[i][0]].push_back({ R[i][1], L[i] });
graph[R[i][1]].push_back({ R[i][0], L[i] });
}
priority_queue<pii, vector<pii>, greater<pii> > pq;
vector<bool> vis(N);
vector<ll> dist(N, 1e18);
vector<ll> ans[N];
for(int i=0; i<K; i++) {
dist[P[i]] = 0;
pq.push({ 0, P[i] });
}
while(!pq.empty()) {
auto [d, u] = pq.top(); pq.pop();
if(ans[u].size() >= 2) continue;
ans[u].push_back(d);
for(auto &[v, w] : graph[u]) {
if(dist[v] > d + w) {
dist[v] = d + w;
pq.push({ d + w, v });
}
}
}
sort(ans[0].begin(), ans[0].end());
return ans[0].back();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |