Submission #1087972

# Submission time Handle Problem Language Result Execution time Memory
1087972 2024-09-13T16:06:49 Z T0p_ Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_N = 100000 + 5;
 
struct Dijkstra {
  int node;
  long long weight;
 
  bool operator < (const Dijkstra & o) const {
    return weight > o.weight;
  }
};
 
long long mn_1[MAX_N], mn_2[MAX_N];
vector<pair<int, long long>> g[MAX_N];
 
bool update(int u, long long v) {
  if (v < mn_1[u]) {
    mn_2[u] = mn_1[u];
    mn_1[u] = v;
    return true;
  }
  else if (v < mn_2[u]) {
    mn_2[u] = v;
    return true;
  }
 
  return false;
}
 
long long travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
  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] });
  }
 
  for (int i=0 ; i<N ; i++) {
    mn_1[i] = mn_2[i] = 2e9;
  }
 
  priority_queue<Dijkstra> dijkstra;
 
  for (int i=0 ; i<K ; i++) {
    mn_1[P[i]] = mn_2[P[i]] = 0;
    dijkstra.push({ P[i], 0 });
  }
 
  while (!dijkstra.empty()) {
    int node = dijkstra.top().node;
    long long weight = dijkstra.top().weight;
    dijkstra.pop();
 
    if (weight != mn_2[node]) continue;
 
    for (pair<int, long long> edge : g[node]) {
      if (update(edge.first, weight + edge.second) && edge.first != 0) {
        dijkstra.push({ edge.first, mn_2[edge.first] });
      }
    }
  }
  return mn_2[0];
}

Compilation message

crocodile.cpp:34:11: error: ambiguating new declaration of 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)'
   34 | long long travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
      |           ^~~~~~~~~~~
In file included from crocodile.cpp:1:
crocodile.h:1:5: note: old declaration 'int travel_plan(int, int, int (*)[2], int*, int, int*)'
    1 | int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]);
      |     ^~~~~~~~~~~