Submission #1325437

#TimeUsernameProblemLanguageResultExecution timeMemory
1325437zwezdinvCyberland (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] = 0;
    for (int iter = 0; iter <= k; ++iter) {
        std::vector<double> ndist(n, 1e18);
        std::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 (u == h) continue;
            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:15:94: error: wrong number of template arguments (3, should be at least 1)
   15 |         std::queue<std::pair<double, int>, std::vector<std::pair<double, int>>, std::greater<>> pq;
      |                                                                                              ^~
In file included from /usr/include/c++/13/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from cyberland.cpp:1:
/usr/include/c++/13/bits/stl_queue.h:96:11: note: provided for 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
cyberland.cpp:17:16: error: request for member 'emplace' in 'pq', which is of non-class type 'int'
   17 |             pq.emplace(dist[i], i);
      |                ^~~~~~~
cyberland.cpp:19:19: error: request for member 'size' in 'pq', which is of non-class type 'int'
   19 |         while (pq.size()) {
      |                   ^~~~
cyberland.cpp:20:30: error: request for member 'top' in 'pq', which is of non-class type 'int'
   20 |             auto [d, u] = pq.top();
      |                              ^~~
cyberland.cpp:21:16: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   21 |             pq.pop();
      |                ^~~
cyberland.cpp:28:24: error: request for member 'emplace' in 'pq', which is of non-class type 'int'
   28 |                     pq.emplace(dist[to] = nd, to);
      |                        ^~~~~~~