Submission #469720

# Submission time Handle Problem Language Result Execution time Memory
469720 2021-09-01T16:27:15 Z Soumya1 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
600 ms 63156 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
  vector<pair<int, int>> ad[n];
  for (int i = 0; i < m; i++) {
    ad[r[i][0]].push_back({r[i][1], l[i]});
    ad[r[i][1]].push_back({r[i][0], l[i]});
  }
  vector<int> d1(n, 1e9 + 5);
  vector<int> d2(n, 1e9 + 5);
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < k; i++) {
    d1[p[i]] = d2[p[i]] = 0;
    pq.push({0, p[i]});
  }
  vector<bool> vis(n, false);
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (auto [v, w] : ad[u]) {
      if (d1[v] >= d2[u] + w) {
        d2[v] = d1[v];
        d1[v] = d2[u] + w;
        pq.push({-d2[v], v});
      } else if (d2[v] > d2[u] + w) {
        d2[v] = d2[u] + w;
        pq.push({-d2[v], v});
      }
    }
  }
  return d2[0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 2 ms 352 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 4 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 2 ms 352 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 4 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 511 ms 56828 KB Output is correct
17 Correct 98 ms 14784 KB Output is correct
18 Correct 122 ms 16372 KB Output is correct
19 Correct 600 ms 63156 KB Output is correct
20 Correct 294 ms 47212 KB Output is correct
21 Correct 46 ms 6384 KB Output is correct
22 Correct 331 ms 44624 KB Output is correct