이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    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<long long> cnt[N];
    bool vis[N];
    long long dist[N];
    memset(vis,0,sizeof(vis));
    memset(dist,127,sizeof(dist));
    priority_queue<pair<long long,int>,vector<pair<long long,int> >,greater<pair<int,int> > > pq;
    for(int i=0;i<K;i++){
        dist[P[i]] = 0;
        pq.emplace(dist[P[i]],P[i]);
    }
    while(!pq.empty()){
        auto curr = pq.top();
        pq.pop();
        if(vis[curr.second]) continue;
        vis[curr.second] = true;
        for(auto it : adj[curr.second]){
            cnt[it.first].emplace(curr.first+it.second);
            while(cnt[it.first].size() > 2)cnt[it.first].pop();
            if(cnt[it.first].size() > 1 && dist[it.first] > cnt[it.first].top()){
                dist[it.first] = cnt[it.first].top();
                pq.emplace(dist[it.first],it.first);
            }
        }
    }
    return dist[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... |