Submission #1325428

#TimeUsernameProblemLanguageResultExecution timeMemory
1325428zwezdinv사이버랜드 (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    k = std::min(k, 60);
    std::vector<std::vector<std::pair<int, int>>> adj(n);
    for (int i = 0; i < m; ++i) {
        adj[x[i]].emplace_back(y[i], c[i]);
        adj[y[i]].emplace_back(x[i], c[i]);
    }
    double ans = 1e18;
    std::vector<double> dist(n, 1e18);
    dist[0] = h;
    for (int iter = 0; iter <= k; ++iter) {
        std::vector<bool> ndist(n, 1e18);
        std::priority_queue<std::pair<double, int>, std::vector<std::pair<double, int>>, std::greater<>> pq;
        for (int i = 0; i < n; ++i) {
            pq.emplace(dist[i], i);
        }
        while (pq.size()) {
            auto [d, u] = pq.top();
            pq.pop();
            if (d > dist[u]) continue;
            for (auto [to, w] : adj[u]) {
                double nd = d + w;
                if (arr[to] == 0) nd = 0;
                if (dist[to] > nd) {
                    pq.emplace(dist[to] = nd, to);
                }
                if (arr[to] == 2) {
                    ndist[to] = std::min(ndist[to], nd / 2);
                }
            }
        }
        ans = std::min(ans, dist[h]);
        dist = ndist;
    }
    if (ans > 1e17) return -1;
    return ans;
}
// int main() {
//     int n, m, k, h;
//     std::cin >> n >> m >> k >> h;
//     std::vector<
//     std::vector<int> a(n);
//     for (auto& i : a) std::cin >> i;
//     std::cout << sequence(n, a);
// }

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:30:41: error: no matching function for call to 'min(std::vector<bool>::reference, double)'
   30 |                     ndist[to] = std::min(ndist[to], nd / 2);
      |                                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from cyberland.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
cyberland.cpp:30:41: note:   deduced conflicting types for parameter 'const _Tp' ('std::_Bit_reference' and 'double')
   30 |                     ndist[to] = std::min(ndist[to], nd / 2);
      |                                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
cyberland.cpp:30:41: note:   deduced conflicting types for parameter 'const _Tp' ('std::_Bit_reference' and 'double')
   30 |                     ndist[to] = std::min(ndist[to], nd / 2);
      |                                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
cyberland.cpp:30:41: note:   'std::_Bit_reference' is not derived from 'std::initializer_list<_Tp>'
   30 |                     ndist[to] = std::min(ndist[to], nd / 2);
      |                                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
cyberland.cpp:30:41: note:   'std::_Bit_reference' is not derived from 'std::initializer_list<_Tp>'
   30 |                     ndist[to] = std::min(ndist[to], nd / 2);
      |                                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~
cyberland.cpp:35:16: error: no match for 'operator=' (operand types are 'std::vector<double>' and 'std::vector<bool>')
   35 |         dist = ndist;
      |                ^~~~~
In file included from /usr/include/c++/13/vector:72,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = double; _Alloc = std::allocator<double>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'const std::vector<double>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/13/vector:66:
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = double; _Alloc = std::allocator<double>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'std::vector<double>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = double; _Alloc = std::allocator<double>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'std::initializer_list<double>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~