이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
int time1[100010],time2[100010],n,m;
std::vector<std::vector<std::pair<int,int>>>a;
std::priority_queue<std::pair<int,int>>q;
bool viz[100010];
void lee()
{
    while(!q.empty())
    {
        int val=-q.top().first;
        int nod=q.top().second;
        q.pop();
        if(viz[nod]==true)
            continue;
        viz[nod]=true;
        for(auto x:a[nod])
        {
            if(time1[x.first]==0||time1[x.first]>val+x.second)
            {
                time2[x.first]=time1[x.first];
                time1[x.first]=val+x.second;
                if(time2[x.first]!=0)
                    q.push({-time2[x.first],x.first});
            }
            else if(time2[x.first]==0||time2[x.first]>val+x.second)
            {
                time2[x.first]=val+x.second;
                q.push({-time2[x.first],x.first});
            }
        }
    }
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N;
    m=M;
    a.resize(n+5);
    for(int i=0;i<m;++i)
    {
        a[R[i][0]].push_back({R[i][1],L[i]});
        a[R[i][1]].push_back({R[i][0],L[i]});
    }
    for(int i=0;i<K;++i)
    {
        time1[P[i]]=time2[P[i]]=1;
        q.push({-1,P[i]});
    }
    lee();
    return time2[0]-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... |