이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, int>
#define maxn 100010
const ll bil = 2000000000LL;
vector<vector<pii>> adj(maxn);
ll dist[maxn][2];
priority_queue<pii, vector<pii>, greater<pii>> pq;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for (int i = 0; i < N; i++) {
		dist[i][0] = dist[i][1] = bil;
	}
	int v;
	for (int i = 0; i < K; i++) {
		v = P[i];
		dist[v][0] = dist[v][1] = 0;
		pq.push(pii(0, v));
	}
	for (int i = 0; i < M; i++) {
		adj[R[i][0]].push_back(pii(R[i][1], L[i]));
		adj[R[i][1]].push_back(pii(R[i][0], L[i]));
	}
	ll d;
	while (!pq.empty()) {
		d = pq.top().first;
		v = pq.top().second;
		// cout << v << " : " << d << endl;
		pq.pop();
		if (dist[v][1] < d) continue;
		for (pii vv : adj[v]) {
			ll odist = dist[vv.first][1];
			if (d + vv.second < dist[vv.first][0]) {
				dist[vv.first][1] = dist[vv.first][0];
				dist[vv.first][0] = d + vv.second;
				if (dist[vv.first][1] != odist) 
					pq.push(pii(dist[vv.first][1], vv.first));
			}
			else if (d + vv.second < dist[vv.first][1]) {
				dist[vv.first][1] = d + vv.second;
				if (dist[vv.first][1] != odist) 
					pq.push(pii(dist[vv.first][1], vv.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... |