Submission #862829

#TimeUsernameProblemLanguageResultExecution timeMemory
862829BerryisbetterCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; using ll = double; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; const ld INF = 1e16; vector<ld> v; vector<vector<pair<ll, ll>>>g; ll h,n; void dfs(ll x) { if (v[x]++) return; if ((int)x%(int)n==h) return; for (auto i : g[x]) { dfs(i.first); } } 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) { ll m = M, k = min(K, 70) + 1; h = H, n = N; v = vector<ld>(n * k); g = vector<vector<pair<ll, ll>>>(n * k); for (ll j = 0; j < k; j++) { for (ll i = 0; i < m; i++) { g[x[i] + j * n].push_back({ y[i] + j * n, c[i] * 1.0 / (1ll << (long long)j) }); g[y[i] + j * n].push_back({ x[i] + j * n, c[i] * 1.0 / (1ll << (long long)j) }); if (j && arr[y[i]] == 2) { g[x[i] + j * n].push_back({ y[i] + (j - 1) * n, c[i] * 1.0 / (1ll << (long long)j) }); } if (j && arr[x[i]] == 2) { g[y[i] + j * n].push_back({ x[i] + (j - 1) * n, c[i] * 1.0 / (1ll << (long long)j) }); } } } for (ll i = k-1; i >= 0; i--) { dfs(i * n); } vector<ld> save = v; v = vector<ld>(n * k, INF); priority_queue<pair<ld, ld>, vector<pair<ld, ld>>, greater<pair<ld, ld>>> q; for (ll i = 0; i < k; i++) { q.push({ 0,i*n }); v[i*n] = 0; } for (ll j = 0; j < k; j++) { for (ll i = 0; i < n; i++) { if (arr[i] == 0&&save[i+j*n]) { q.push({ 0, i + j * n }); v[i + j * n] = 0; } } } save = vll(n*k); while (q.size()) { ll ce= q.top().second; q.pop(); if (((int)ce%(int)n)==h) { continue; } if (!save[ce]++) { for (auto i : g[ce]) { if (v[i.first] > v[ce] + i.second) { v[i.first] = v[ce] + i.second; q.push({ v[i.first],i.first }); } } } } if (v[h] >= INF) { return -1; } return v[h]; }

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:53:16: error: no match for 'operator=' (operand types are 'std::vector<long double>' and 'vll' {aka 'std::vector<double>'})
   53 |  save = vll(n*k);
      |                ^
In file included from /usr/include/c++/10/vector:72,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long double; _Alloc = std::allocator<long double>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<double>'} to 'const std::vector<long double>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long double; _Alloc = std::allocator<long double>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<double>'} to 'std::vector<long double>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long double; _Alloc = std::allocator<long double>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<double>'} to 'std::initializer_list<long double>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~