이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;
struct node {
    int v;
    long long time;
    bool operator<(const node &rhs) const {
        return time > rhs.time;
    }
};
int travel_plan(int n, int m, int R[][2], int L[], int k, int p[]) {
    vector<pair<int, long long>> adj[n + 1];
    for (int i = 0; i < m; i++) {
        int a = R[i][0], b = R[i][1];
        long long c = L[i];
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }
    vector<int> vis(n + 1, 0);
    priority_queue<node> q;
    for (int i = 0; i < k; i++) {
        q.push({p[i], 0}), vis[p[i]] = 1;
    }
    while (!q.empty()) {
        node v = q.top();
        q.pop();
        vis[v.v]++;
        if (vis[v.v] != 2) continue;
        if (v.v == 0) {
            return v.time;
        }
        for (auto u : adj[v.v]) {
            q.push({u.first, u.second + v.time});
        }
    }
    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... |