Submission #1264528

#TimeUsernameProblemLanguageResultExecution timeMemory
1264528marcus06Crocodile's Underground City (IOI11_crocodile)C++20
Compilation error
0 ms0 KiB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

#ifdef LOCAL
#include </home/marcus06/CP/Library/debug.h>
#else
#define debug(...) 
#endif

/*How to use:
  Tvector <int, 2> g(n); //graph
  Tvector <int, 3> f(n, k, 2) = f[n][k][2]
*/
template <class Tp, int D = 1>
struct Tvector : public vector<Tvector<Tp, D - 1>> {
  template <class... Args>
  Tvector(int n = 0, Args... args) : vector<Tvector<Tp, D - 1>>(n, Tvector<Tp, D - 1>(args...)) {}
};
 
template <class Tp>
struct Tvector<Tp, 1> : public vector<Tp> {
  Tvector(int n = 0, Tp val = Tp()) : vector<Tp>(n, val) {}
};

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    Tvector <int, 2> graph(N);
    for (int i = 0; i < M; ++i) {
        int u = R[i][0], v = R[i][1];
        graph[u].emplace_back(v, L[i]);
        graph[v].emplace_back(u, L[i]);
    }

    priority_queue <pair <lli, int>> Q;
    vector <bool> vis(N);
    vector <lli> dist(N, -1);

    dist[0] = 0;
    Q.emplace(0, 0);
    while (!Q.empty()) {
        auto [d, u] = Q.front(); Q.pop();
        if (vis[u]) continue;
        vis[u] = true;

        for (auto [v, w]: graph[u]) {
            if (dist[v] == -1 || dist[v] > dist[u] + w) {
                dist[v] = dist[u] + w;
                Q.emplace(-dist[v], v);
            }
        }
    }

    lli ans = 0;
    for (int i = 0; i < K; ++i) {
        ans = max(ans, dist[P[i]]);
    }
    return ans;
}

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:42:25: error: 'class std::priority_queue<std::pair<long long int, int> >' has no member named 'front'
   42 |         auto [d, u] = Q.front(); Q.pop();
      |                         ^~~~~
In file included from /usr/include/c++/11/ext/alloc_traits.h:34,
                 from /usr/include/c++/11/bits/basic_string.h:40,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from crocodile.cpp:2:
/usr/include/c++/11/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {int&, int&}; _Tp = int; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<int>]':
/usr/include/c++/11/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&]'
crocodile.cpp:31:30:   required from here
/usr/include/c++/11/bits/alloc_traits.h:518:28: error: no matching function for call to 'construct_at(int*&, int&, int&)'
  518 |           std::construct_at(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_iterator.h:85,
                 from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from crocodile.cpp:2:
/usr/include/c++/11/bits/stl_construct.h:94:5: note: candidate: 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)'
   94 |     construct_at(_Tp* __location, _Args&&... __args)
      |     ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_construct.h:94:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/stl_construct.h: In substitution of 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = int; _Args = {int&, int&}]':
/usr/include/c++/11/bits/alloc_traits.h:518:21:   required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {int&, int&}; _Tp = int; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<int>]'
/usr/include/c++/11/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&]'
crocodile.cpp:31:30:   required from here
/usr/include/c++/11/bits/stl_construct.h:96:17: error: new initializer expression list treated as compound expression [-fpermissive]
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~