Submission #1357351

#TimeUsernameProblemLanguageResultExecution timeMemory
1357351kawhietGame (APIO22_game)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;

int n, k;
vector<vector<int>> g;
vector<bool> vis;

void dfs(int u) {
    for (auto v : g[u]) {
        if (!vis[v]) {
            vis[v] = true;
            dfs(v);
        }
    }
}

void init(int _n, int _k) {
    n = _n;
    k = _k;
    g.resize(n);
    vis.resize(n);
    for (int i = 0; i <= k - 2; i++) {
        g[i].push_back(i + 1);
    }
}

int add_teleporter(int u, int v) {
    g[u].push_back(v);
    for (int i = 0; i < k; i++) {
        ranges::fill(vis, false);
        dfs(i);
        if (vis[i]) {
            return 1;
        }
    }
    return 0;
}

Compilation message (stderr)

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:31:21: error: no match for call to '(const std::ranges::__fill_fn) (std::vector<bool>&, bool)'
   31 |         ranges::fill(vis, false);
      |         ~~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/bits/ranges_algo.h:38,
                 from /usr/include/c++/13/algorithm:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from game.cpp:1:
/usr/include/c++/13/bits/ranges_algobase.h:563:7: note: candidate: 'template<class _Tp, class _Out, class _Sent>  requires (output_iterator<_Out, const _Tp&>) && (sentinel_for<_Sent, _Out>) constexpr _Out std::ranges::__fill_fn::operator()(_Out, _Sent, const _Tp&) const'
  563 |       operator()(_Out __first, _Sent __last, const _Tp& __value) const
      |       ^~~~~~~~
/usr/include/c++/13/bits/ranges_algobase.h:563:7: note:   template argument deduction/substitution failed:
game.cpp:31:21: note:   candidate expects 3 arguments, 2 provided
   31 |         ranges::fill(vis, false);
      |         ~~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/ranges_algobase.h:589:7: note: candidate: 'template<class _Tp, class _Range>  requires  output_range<_Range, const _Tp&> constexpr std::ranges::borrowed_iterator_t<_Range> std::ranges::__fill_fn::operator()(_Range&&, const _Tp&) const'
  589 |       operator()(_Range&& __r, const _Tp& __value) const
      |       ^~~~~~~~
/usr/include/c++/13/bits/ranges_algobase.h:589:7: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/ranges_algobase.h:589:7: note: constraints not satisfied
In file included from /usr/include/c++/13/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/13/bits/stl_algobase.h:65,
                 from /usr/include/c++/13/algorithm:60:
/usr/include/c++/13/bits/iterator_concepts.h: In substitution of 'template<class _Tp, class _Range>  requires  output_range<_Range, const _Tp&> constexpr std::ranges::borrowed_iterator_t<_Range> std::ranges::__fill_fn::operator()(_Range&&, const _Tp&) const [with _Tp = bool; _Range = std::vector<bool>&]':
game.cpp:31:21:   required from here
/usr/include/c++/13/bits/iterator_concepts.h:562:13:   required for the satisfaction of 'indirectly_writable<_Iter, _Tp>' [with _Iter = std::_Bit_iterator; _Tp = const bool&]
/usr/include/c++/13/bits/iterator_concepts.h:662:13:   required for the satisfaction of 'output_iterator<decltype (std::ranges::__cust_access::__begin(declval<_Container&>())), _Tp>' [with _Range = std::vector<bool, std::allocator<bool> >&; _Tp = const bool&]
/usr/include/c++/13/bits/ranges_base.h:585:13:   required for the satisfaction of 'output_range<_Range, const _Tp&>' [with _Range = std::vector<bool, std::allocator<bool> >&; _Tp = bool]
/usr/include/c++/13/bits/iterator_concepts.h:562:35:   in requirements with '_Out&& __o', '_Tp&& __t' [with _Out = std::_Bit_iterator; _Tp = const bool&]
/usr/include/c++/13/bits/iterator_concepts.h:567:11: note: the required expression 'const_cast<const decltype(*(declval<_Tp&>)())&&>(*__o) =(forward<_Tp>)(__t)' is invalid
  566 |         const_cast<const iter_reference_t<_Out>&&>(*__o)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  567 |           = std::forward<_Tp>(__t);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/iterator_concepts.h:569:11: note: the required expression 'const_cast<const decltype(*(declval<_Tp&>)())&&>(*(forward<_Out>)(__o))=(forward<_Tp>)(__t)' is invalid
  568 |         const_cast<const iter_reference_t<_Out>&&>(*std::forward<_Out>(__o))
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  569 |           = std::forward<_Tp>(__t);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more detail