이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF = 1e18;
struct Comp {
    int nod;
    ll val;
    bool operator <(const Comp &other) const {
        return val > other.val;
    }
};
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    vector < vector < pair <int, int> > > g(N);
    for(int i = 0; i < M; i++) {
        g[R[i][0]].push_back({R[i][1], L[i]});
        g[R[i][1]].push_back({R[i][0], L[i]});
    }
    priority_queue <Comp> pq;
    vector <ll> dst(N, INF);
    vector <int> cnt(N);
    for(int i = 0; i < K; i++) {
        dst[P[i]] = 0;
        pq.push({P[i], 0});
        cnt[P[i]] = 1;
    }
    while(pq.size()) {
        auto cur = pq.top();
        pq.pop();
        if(cnt[cur.nod] == 2) {
            continue;
        }
        cnt[cur.nod]++;
        dst[cur.nod] = cur.val;
        if(cnt[cur.nod] == 2) {
            for(auto it : g[cur.nod]) {
                pq.push({it.first, cur.val + it.second});
            }
        }
    }
    return (int) dst[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... |