Submission #569367

# Submission time Handle Problem Language Result Execution time Memory
569367 2022-05-27T10:53:14 Z codebuster_10 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
629 ms 61076 KB
#include <bits/stdc++.h>
using namespace std ;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){

  const int inf = 2e9;

  vector<pair<int,int>> dis(N,{inf,inf});

  vector<vector<pair<int,int>>> g(N);

  for(int e = 0; e < M; ++e){
    int u = R[e][0], v = R[e][1], w = L[e];
    g[u].emplace_back(v,w);
    g[v].emplace_back(u,w);
  }

  priority_queue<pair<int,int>> pq;

  for(int i = 0; i < K; ++i){
    int u = P[i];
    dis[u] = {0,0};
    pq.push({-dis[u].second,u});
  }

  while(!pq.empty()){
    auto [d,i] = pq.top(); pq.pop();

    if(-d != dis[i].second)
      continue;

    for(auto [j,w] : g[i]){
      vector<int> prv = {dis[j].first,dis[j].second};
      prv.push_back(w + dis[i].second);
      auto now = prv;
      sort(now.begin(), now.end());
      dis[j].first = now[0];
      dis[j].second = now[1];

      if(prv[1] != now[1]){
        pq.push({-dis[j].second,j});
      }
    }

  }

  return dis[0].second;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 572 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 360 KB Output is correct
12 Correct 5 ms 804 KB Output is correct
13 Correct 4 ms 816 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 572 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 360 KB Output is correct
12 Correct 5 ms 804 KB Output is correct
13 Correct 4 ms 816 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 521 ms 55748 KB Output is correct
17 Correct 97 ms 13740 KB Output is correct
18 Correct 117 ms 15172 KB Output is correct
19 Correct 629 ms 61076 KB Output is correct
20 Correct 390 ms 47172 KB Output is correct
21 Correct 53 ms 6036 KB Output is correct
22 Correct 381 ms 44352 KB Output is correct