이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector<vector<pair<int, int>>> adj(N);
for (int i = 0; i < M; ++i) {
adj[R[i][0]].emplace_back(R[i][1], L[i]);
adj[R[i][1]].emplace_back(R[i][0], L[i]);
}
priority_queue<pair<int, int>> q;
vector<bool> foo(N), bar(N);
for (int i = 0; i < K; ++i) {
foo[P[i]] = true;
q.emplace(0, P[i]);
}
while (!q.empty()) {
int x = q.top().second, d = -q.top().first;
q.pop();
if (!foo[x]) {
foo[x] = true;
continue;
}
if (!bar[x]) {
bar[x] = true;
if (!x) {
return d;
}
for (auto p : adj[x]) {
int y = p.first, w = p.second;
if (!bar[y]) {
q.emplace(-(d + w), y);
}
}
}
}
return -1;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |