이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
std::vector <std::vector <std::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]);
}
std::vector <int> cnt(n, 0);
std::priority_queue <std::pair <long long, int>> pq;
for (int i = 0; i < k; i++) {
cnt[p[i]] = 1;
pq.push({ 0, p[i] });
}
while (pq.size()) {
long long w = -pq.top().first;
int v = pq.top().second;
pq.pop();
if (cnt[v] >= 2) {
continue;
}
cnt[v]++;
if (cnt[v] == 1) {
continue;
}
assert(cnt[v] == 2);
if (!v) {
return w;
}
for (auto q : g[v]) {
pq.push({ -w - q.second, q.first });
}
}
assert(false);
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |