Submission #955355

# Submission time Handle Problem Language Result Execution time Memory
955355 2024-03-30T08:16:39 Z blackslex Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
1 ms 4444 KB
#include "crocodile.h"
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

ll n, m, k;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
  n = N; m = M; k = K;
  vector<vector<pii>> v(n, vector<pii>());
  for (int i = 0; i < m; i++) v[R[i][0]].emplace_back(R[i][1], L[i]), v[R[i][1]].emplace_back(R[i][0], L[i]);
  for (int i = 0; i < n; i++) sort(v[i].begin(), v[i].end(), [&] (const pii &p1, const pii &p2) {
    return p1.second < p2.second;
  });
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  vector<ll> d(n, 1e18);
  vector<bool> f(n);
  pq.emplace(d[0] = 0, 0);
  while (!pq.empty()) {
    auto [nd, nn] = pq.top(); pq.pop();
    if (f[nn]) continue; f[nn] = 1;
    for (int i = 1; i < v[nn].size(); i++) {
      auto [tn, td] = v[nn][i];
      if (d[tn] > d[nn] + td) pq.emplace(d[tn] = d[nn] + td, tn);
    }
  }
  ll ans = 1e18;
  for (int i = 0; i < k; i++) ans = min(ans, d[P[i]]);
  return ans;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:23:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   23 |     if (f[nn]) continue; f[nn] = 1;
      |     ^~
crocodile.cpp:23:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   23 |     if (f[nn]) continue; f[nn] = 1;
      |                          ^
crocodile.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 1; i < v[nn].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -