Submission #1060979

#TimeUsernameProblemLanguageResultExecution timeMemory
1060979Halym2007Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //#include "cyberland.h" using namespace std; #define ll long long #define sz size() #define ff first #define ss second #define pb push_back #define pii pair <ll, ll> const int N = 2e5 + 5; vector <pii> v[N]; ll dis[N]; priority_queue <pair <ll, ll>, vector<pair <ll, ll>>, greater <pair <ll, ll>>> q; ll n, m, k, h, vis[N]; vector <ll> a, tt; void dfs (ll x) { vis[x] = 1; if (a[x] == 0) { tt.pb (x); } for (pii i : v[x]) { if (vis[i.ff]) continue; dfs(i.ff); } } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { n = N;m = M;k = K;h = H; a = arr; // assert (h != 0); for (ll i = 0; i < m; ++i) { v[x[i]].pb ({y[i], c[i]}); v[y[i]].pb ({x[i], c[i]}); } for (ll i = 0; i < n; ++i) { dis[i] = 1e16; } q.push ({0, h}); dis[h] = 0; while (!q.empty()) { ll x = q.top().ss; q.pop(); for (pii i : v[x]) { if (dis[i.ff] > dis[x] + i.ss) { dis[i.ff] = dis[x] + i.ss; q.push({dis[i.ff], i.ff}); } } } double jogap = 1e16; jogap = min (jogap, (double)dis[0]); vis[h] = 1; dfs (0); for (ll i : tt) { jogap = min (jogap, (double)dis[i]); } if (jogap == (double)1e16) jogap = -1; for (ll i = 0; i < n; ++i) { v[i].clear(); vis[i] = 0; } return jogap; } //int main() { // freopen ("input.txt", "r", stdin); // int T; // assert(1 == scanf("%d", &T)); // while (T--){ // int N,M,K,H; // assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H)); // std::vector<int> x(M); // std::vector<int> y(M); // std::vector<int> c(M); // std::vector<int> arr(N); // for (ll i=0;i<N;i++) // assert(1 == scanf("%d", &arr[i])); // for (ll i=0;i<M;i++) // assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i])); // prllf("%.12lf\n", solve(N, M, K, H, x, y, c, arr)); // } //} /* 1 3 2 30 2 1 2 1 1 2 12 2 0 4 answer : 4.00000000000 1 4 4 30 3 1 0 2 1 0 1 5 0 2 4 1 3 2 2 3 4 answer : 2.00000000000 */

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:32:6: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   32 |  a = arr;
      |      ^~~
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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 long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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 long int; _Alloc = std::allocator<long long int>]'
  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 'std::vector<int>' to 'std::vector<long long int>&&'
  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 long int; _Alloc = std::allocator<long long int>]'
  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 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~