Submission #1340659

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

#define int long long

constexpr int N = 5001;

vector<int> d;
vector<vector<int>> g;

void bfs(int u) {
    queue<int> q;
    q.push(u);
    d[u] = 0;
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (auto y : g[x]) {
            if (d[y] == -1) {
                d[y] = d[x] + 1;
                q.push(y);
            }
        }
    }
}

int dist;
vector<bool> vis;
vector<int> x, y, ways;

void go(int st) {
    queue<int> q;
    q.push(st);
    vis[st] = 1;
    ways[st] = 1;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : g[u]) {
            if (!vis[v] && x[v] + y[v] == dist) {
                vis[v] = 1;
                ways[v] += ways[u];
                q.push(v);
            }
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    d.resize(n);
    g.resize(n);
    vis.resize(n);
    ways.resize(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<double> ans(n);
    int k;
    cin >> k;
    while (k--) {
        int a, b;
        cin >> a >> b;
        ranges::fill(d, -1); bfs(a); x = d;
        ranges::fill(d, -1); bfs(b); y = d;
        dist = x[b];
        ranges::fill(vis, false);
        ranges::fill(ways, 0);
        go(a);
        int tot = ways[b];
        for (int i = 0; i < n; i++) {
            if (x[i] + y[i] == dist) {
                ans[i] += double(tot) / double(ways[i]);
            }
        }
    }
    double mx = ranges::max(ans);
    for (int i = 0; i < n; i++) {
        if (ans[i] == mx) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}

Compilation message (stderr)

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