Submission #740492

# Submission time Handle Problem Language Result Execution time Memory
740492 2023-05-12T15:11:27 Z abczz Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#define ll long long

using namespace std;

vector <array<ll, 2> > adj[100000];
priority_queue <array<ll, 2>, vector<array<ll, 2>>, greater<array<ll,2>>> pq;
ll dist[100000], in[100000], MN[2][100000];
ll travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  for (int i=0; i<N; ++i) dist[i] = MN[0][i] = MN[1][i] = 1e18;
  for (int i=0; i<M; ++i) {
    adj[R[i][0]].push_back({R[i][1], L[i]});
    adj[R[i][1]].push_back({R[i][0], L[i]});
  }
  for (int i=0; i<K; ++i) {
    dist[P[i]] = 0;
    pq.push({0, P[i]});
  }
  while (!pq.empty()) {
    auto [w, u] = pq.top();
    pq.pop();
    if (dist[u] != w) continue;
    for (auto [v, x] : adj[u]) {
      if (dist[v] > dist[u]+x) {
        ++in[v];
        if (in[v] == 1) MN[0][v] = dist[u]+x;
        else if (in[v] == 2) {
          MN[1][v] = max(MN[0][v], dist[u]+x);
          MN[0][v] = min(MN[0][v], dist[u]+x);
          dist[v] = MN[1][v];
          pq.push({dist[v], v});
        }
        else {
          if (MN[0][v] > dist[u]+x) {
            MN[1][v] = MN[0][v];
            MN[0][v] = dist[u]+x;
            if (dist[v] != MN[1][v]) pq.push({MN[1][v], v});
            dist[v] = MN[1][v];
          }
          else if (MN[1][v] > dist[u]+x) {
            MN[1][v] = dist[u]+x;
            dist[v] = MN[1][v];
            pq.push({dist[v], v});
          }
        }
      }
    }
  }
  return dist[0];
}

Compilation message

crocodile.cpp:13:4: error: ambiguating new declaration of 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)'
   13 | ll 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[]);
      |     ^~~~~~~~~~~
crocodile.cpp: In function 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:25:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |     auto [w, u] = pq.top();
      |          ^
crocodile.cpp:28:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |     for (auto [v, x] : adj[u]) {
      |               ^