Submission #103738

# Submission time Handle Problem Language Result Execution time Memory
103738 2019-04-02T11:29:08 Z wxh010910 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
819 ms 66672 KB
#include <bits/stdc++.h>
#include "crocodile.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>>> adj(N);
  for (int i = 0; i < M; ++i) {
    adj[R[i][0]].emplace_back(R[i][1], L[i]);
    adj[R[i][1]].emplace_back(R[i][0], L[i]);
  }
  priority_queue<pair<int, int>> q;
  vector<bool> foo(N), bar(N);
  for (int i = 0; i < K; ++i) {
    foo[P[i]] = true;
    q.emplace(0, P[i]);
  }
  while (!q.empty()) {
    int x = q.top().second, d = -q.top().first;
    q.pop();
    if (!foo[x]) {
      foo[x] = true;
      continue;
    }
    if (!bar[x]) {
      bar[x] = true;
      if (!x) {
        return d;
      }
      for (auto p : adj[x]) {
        int y = p.first, w = p.second;
        if (!bar[y]) {
          q.emplace(-(d + w), y);
        }
      }
    }
  }
  return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 484 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 484 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 8 ms 1024 KB Output is correct
13 Correct 6 ms 1104 KB Output is correct
14 Correct 3 ms 372 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 484 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 8 ms 1024 KB Output is correct
13 Correct 6 ms 1104 KB Output is correct
14 Correct 3 ms 372 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 706 ms 62712 KB Output is correct
17 Correct 105 ms 13048 KB Output is correct
18 Correct 123 ms 14540 KB Output is correct
19 Correct 819 ms 66672 KB Output is correct
20 Correct 437 ms 55624 KB Output is correct
21 Correct 64 ms 5880 KB Output is correct
22 Correct 483 ms 44568 KB Output is correct