Submission #1077159

# Submission time Handle Problem Language Result Execution time Memory
1077159 2024-08-27T02:00:36 Z juicy Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
637 ms 75440 KB
#include "crocodile.h"

#include <bits/stdc++.h>

int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
  std::vector<std::vector<std::array<int, 2>>> g(n);
  for (int i = 0; i < m; ++i) {
    g[R[i][0]].push_back({R[i][1], L[i]});
    g[R[i][1]].push_back({R[i][0], L[i]});
  }
  std::vector<int> d(n), vis(n);
  std::priority_queue<std::array<int, 2>, std::vector<std::array<int, 2>>, std::greater<std::array<int, 2>>> pq;
  for (int i = 0; i < k; ++i) {
    int u = P[i];
    vis[u] = 1;
    pq.push({0, u});
  }
  while (pq.size()) {
    auto [c, u] = pq.top(); pq.pop();
    if (vis[u] == 2) {
      continue;
    }
    if (++vis[u] == 2) {
      d[u] = c;
      for (auto [v, w] : g[u]) {
        pq.push({c + w, v});
      }
    }
  }
  return d[0];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 616 KB Output is correct
12 Correct 4 ms 1220 KB Output is correct
13 Correct 4 ms 1372 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 616 KB Output is correct
12 Correct 4 ms 1220 KB Output is correct
13 Correct 4 ms 1372 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 606 ms 71288 KB Output is correct
17 Correct 59 ms 13652 KB Output is correct
18 Correct 83 ms 15396 KB Output is correct
19 Correct 637 ms 75440 KB Output is correct
20 Correct 465 ms 63860 KB Output is correct
21 Correct 34 ms 5976 KB Output is correct
22 Correct 431 ms 44928 KB Output is correct