이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct Node {
    ll i, t;
    bool operator <(const Node& other) const {
        return t > other.t;
    }
};
const ll N = 1e5 + 10, INF = 1e18;
priority_queue<Node> q;
vector<ll> adj[N], len[N];
ll n, m, dist[N][2];
void Dijkstra() {
    while(!q.empty()) {
        Node node = q.top();
        q.pop();
        int i = node.i, t = adj[i].size();
        if(dist[i][1] == node.t) {
            for(int j = 0; j < t; j++) {
                ll nex = adj[i][j],
                   time = dist[i][1] + len[i][j];
                   
                if(time < dist[nex][0])
                    swap(time, dist[nex][0]);
                if(time < dist[nex][1]) {
                    swap(time, dist[nex][1]);
                    q.push({nex, dist[nex][1]});
                }
            }
        }
    }
}
int travel_plan(int n1, int m1, int R[][2], int L[], int K, int P[]) {
    n = n1, m = m1;
    for(int i = 0; i < m; i++) {
        len[R[i][0]].push_back(L[i]);
        len[R[i][1]].push_back(L[i]);
        adj[R[i][0]].push_back(R[i][1]);
        adj[R[i][1]].push_back(R[i][0]);
    }
    for(int i = 0; i < n; i++)
        dist[i][0] = dist[i][1] = INF;
    for(int i = 0; i < K; i++)
        dist[P[i]][0] = dist[P[i]][1] = 0;
    for(int i = 0; i < K; i++)
        q.push({P[i], 0});
    Dijkstra();
    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... |