Submission #1337568

#TimeUsernameProblemLanguageResultExecution timeMemory
1337568kawhietPaths (BOI18_paths)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int64_t ans = -n;
  vector<bool> vis(k);
  auto dfs = [&](auto&& self, int u, int len = 0) -> void {
    if (len == k + 1) {
      return;
    }
    ans++;
    for (auto v : g[u]) {
      if (!vis[a[v]]) {
        vis[a[v]] = true;
        self(self, v, len + 1);
        vis[a[v]] = false;
      }
    }
  };
  for (int i = 0; i < n; i++) {
    ranges::fill(vis, false);
    vis[a[i]] = 1;
    dfs(dfs, i);
  }
  cout << ans << '\n';
  return 0;
}

Compilation message (stderr)

paths.cpp: In function 'int main()':
paths.cpp:38:17: error: no match for call to '(const std::ranges::__fill_fn) (std::vector<bool>&, bool)'
   38 |     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 paths.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:
paths.cpp:38:17: note:   candidate expects 3 arguments, 2 provided
   38 |     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>&]':
paths.cpp:38:17:   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