#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
const ll INF = 1e18;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector<vector<pii>> 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]});
}
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> q;
vector<int> cnt(N, 0);
vector<ll> di(N, INF);
for (int i = 0; i < K; i++) {
cnt[P[i]] = 2, di[P[i]] = 0;
q.push({0, P[i]});
}
while (!q.empty()) {
auto [dist, u] = q.top();
q.pop();
cnt[u]++;
if (cnt[u] == 2) di[u] = dist;
if (cnt[u] != 2 || di[u] != dist) continue;
for (auto& [v, w] : adj[u]) {
if (cnt[v] < 2 && di[v] > di[u] + w) {
q.push({di[u] + w, v});
}
}
}
return di[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |