Submission #433431

# Submission time Handle Problem Language Result Execution time Memory
433431 2021-06-19T19:01:33 Z MilosMilutinovic Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1186 ms 75456 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<vector<pair<int, int>>> 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]});
  }
  const int inf = 1e9 + 1;
  vector<int> dist(n, inf);
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
  for (int i = 0; i < k; i++) {
    for (auto& e : g[p[i]]) {
      que.push({e.second, e.first});
    }
    dist[p[i]] = 0;
  }
  vector<int> cnt(n);
  while (!que.empty()) {
    auto x = que.top();
    que.pop();
    if (dist[x.second] != inf) {
      continue;
    }
    cnt[x.second]++;
    if (cnt[x.second] == 2) {
      dist[x.second] = x.first;
      for (auto y : g[x.second]) {
        que.push({x.first + y.second, y.first});
      }
    }
  }
  return dist[0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 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 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 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 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 352 KB Output is correct
9 Correct 4 ms 716 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 8 ms 972 KB Output is correct
13 Correct 8 ms 1100 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 204 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 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 352 KB Output is correct
9 Correct 4 ms 716 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 8 ms 972 KB Output is correct
13 Correct 8 ms 1100 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1031 ms 55048 KB Output is correct
17 Correct 98 ms 13752 KB Output is correct
18 Correct 135 ms 15152 KB Output is correct
19 Correct 1186 ms 75456 KB Output is correct
20 Correct 736 ms 63752 KB Output is correct
21 Correct 61 ms 5952 KB Output is correct
22 Correct 619 ms 44920 KB Output is correct