이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mxN=1e5+5,inf=1e9+10;
vector<pii> graph[mxN];
int dist[mxN][2],seen[mxN],n,m,k,a,b,w;
priority_queue<pii,vector<pii>, greater<pii> > q;
int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]){
    int n=N;
    int m=M;
    int k=K;
    for(int i=0;i<n;i++) 
        dist[i][0]=dist[i][1]=inf;
    for(int i=0;i<m;i++){
        graph[R[i][0]].push_back(pii(R[i][1],W[i]));
        graph[R[i][1]].push_back(pii(R[i][0],W[i]));
    }
    for(int i=0;i<k;i++){
        q.push(pii(0,E[i]));
        dist[E[i]][1]=0;
    }
    while(!q.empty()){
        int at=q.top().second;
        q.pop();
        if(seen[at]) continue;
        seen[at]=true;
        for(pii &i:graph[at]){
            if(dist[at][1]+i.second < dist[i.first][1]){
                dist[i.first][1]=dist[at][1]+i.second;
                if(dist[i.first][1]<dist[i.first][0]) swap(dist[i.first][1],dist[i.first][0]);
                q.push(pii(dist[i.first][1],i.first));
            }
        }
    }
    return dist[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... |