이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const long long inf = 200000000000000;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
  int n = N;
  int m = M;
  int k = K;
  vector<vector<array<long long, 2>>> adj(n);
  for (int i = 0; i < m; i++) {
    int u = R[i][0];
    int v = R[i][1];
    int t = L[i];
    adj[u].push_back({v, t});
    adj[v].push_back({u, t});
  }
  vector<int> leaves(k);
  for (int i = 0; i < k; i++) {
    leaves[i] = P[i];
  }
  priority_queue<array<long long, 2>, vector<array<long long, 2>>, greater<array<long long, 2>>> pQue;
  
  vector<long long> d(n, inf);  // good
  vector<long long> p(n, inf);  // min
  vector<bool> done(n);
  vector<int> cnt(n);
  vector<bool> mark(n);
  for (auto x : leaves) {
    mark[x] = true;
    d[x] = 0;
    p[x] = 0;
    pQue.push({d[x], x});
  }
  while (!pQue.empty()) {
    auto t = pQue.top();
    pQue.pop();
    if (done[t[1]]) {
      continue;
    }
    done[t[1]] = true;
    for (auto x : adj[t[1]]) {
      cnt[x[0]]++;
      if (cnt[x[0]] == 1) {
        d[x[0]] = x[1] + t[0];
        p[x[0]] = x[1] + t[0];
      } else if (cnt[x[0]] == 2) {
        d[x[0]] = max(d[x[0]], x[1] + t[0]);
        p[x[0]] = min(p[x[0]], x[1] + t[0]);
        pQue.push({d[x[0]], x[0]});
      } else {
        if (x[1] + t[0] <= p[x[0]]) {
          d[x[0]] = p[x[0]];
          pQue.push({d[x[0]], x[0]});
          p[x[0]] = x[1] + t[0];
        } else if (x[1] + t[0] < d[x[0]]) {
          d[x[0]] = x[1] + t[0];
          pQue.push({d[x[0]], x[0]});
        }
      }
    }
  }
  return d[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... |