Submission #823716

#TimeUsernameProblemLanguageResultExecution timeMemory
823716hmm789Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "cyberland.h" #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) { #define int long long int cur, num; double d, ans = -1; vector<pair<int, int>> adj[N]; for(int i = 0; i < M; i++) { adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } double dist[N][K+1]; for(int i = 0; i < N; i++) for(int j = 0; j <= K; j++) dist[i][j] = -1; dist[0][0] = 0; priority_queue<tuple<double, int, int>, vector<tuple<double, int, int>>, greater<tuple<double, int, int>>> pq; pq.push({0, 0, 0}); while(!pq.empty()) { tie(d, cur, num) = pq.top(); pq.pop(); for(auto i : adj[cur]) { double nd = d; if(arr[i.first] != 0) nd += i.second; if(dist[i.first][num] == -1 || dist[i.first][num] > nd) { dist[i.first][num] = nd; pq.push({nd, i.first, num}); } if(arr[i.first] == 2) { if(num+1 > K) continue; nd = d+i.second/2.0; if(dist[i.first][num+1] == -1 || dist[i.first][num+1] > nd) { dist[i.first][num+1] = nd; pq.push({nd, i.first, num+1}); } } } } for(int i = 0; i <= K; i++) { if(dist[H][i] != -1) { if(ans == -1) ans = dist[H][i]; else ans = min(ans, dist[H][i]); } } return ans; #undef int }

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:8:5: error: 'vector' was not declared in this scope
    8 |     vector<pair<int, int>> adj[N];
      |     ^~~~~~
cyberland.cpp:8:5: note: suggested alternatives:
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:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
cyberland.cpp:8:12: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    8 |     vector<pair<int, int>> adj[N];
      |            ^~~~
      |            std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
cyberland.cpp:5:17: error: expected primary-expression before 'long'
    5 |     #define int long long
      |                 ^~~~
cyberland.cpp:8:17: note: in expansion of macro 'int'
    8 |     vector<pair<int, int>> adj[N];
      |                 ^~~
cyberland.cpp:10:9: error: 'adj' was not declared in this scope
   10 |         adj[x[i]].push_back({y[i], c[i]});
      |         ^~~
cyberland.cpp:16:5: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   16 |     priority_queue<tuple<double, int, int>, vector<tuple<double, int, int>>, greater<tuple<double, int, int>>> pq;
      |     ^~~~~~~~~~~~~~
      |     std::priority_queue
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:456:11: note: 'std::priority_queue' declared here
  456 |     class priority_queue
      |           ^~~~~~~~~~~~~~
cyberland.cpp:16:20: error: 'tuple' was not declared in this scope; did you mean 'std::tuple'?
   16 |     priority_queue<tuple<double, int, int>, vector<tuple<double, int, int>>, greater<tuple<double, int, int>>> pq;
      |                    ^~~~~
      |                    std::tuple
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/type_traits:2631:11: note: 'std::tuple' declared here
 2631 |     class tuple;
      |           ^~~~~
cyberland.cpp:16:26: error: expected primary-expression before 'double'
   16 |     priority_queue<tuple<double, int, int>, vector<tuple<double, int, int>>, greater<tuple<double, int, int>>> pq;
      |                          ^~~~~~
cyberland.cpp:17:5: error: 'pq' was not declared in this scope
   17 |     pq.push({0, 0, 0});
      |     ^~
cyberland.cpp:19:9: error: 'tie' was not declared in this scope; did you mean 'std::tie'?
   19 |         tie(d, cur, num) = pq.top();
      |         ^~~
      |         std::tie
In file included from /usr/include/c++/10/functional:54,
                 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:2:
/usr/include/c++/10/tuple:1615:5: note: 'std::tie' declared here
 1615 |     tie(_Elements&... __args) noexcept
      |     ^~~
cyberland.cpp:21:22: error: 'adj' was not declared in this scope
   21 |         for(auto i : adj[cur]) {
      |                      ^~~
cyberland.cpp:41:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   41 |             else ans = min(ans, dist[H][i]);
      |                        ^~~
      |                        std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~