Submission #1253820

#TimeUsernameProblemLanguageResultExecution timeMemory
1253820anfiCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 10005;
const int K = 105;
const double INF = 1e18;
const double EPS = 1e-9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int n, m, k;
        cin >> n >> m >> k;
        vector<int> type(n);
        vector<vector<pair<int, int>>> graph(n);
        for (int i = 0; i < n; i++) {
            cin >> type[i];
        }
        for (int i = 0; i < m; i++) {
            int u, v, w;
            cin >> u >> v >> w;
            graph[u].emplace_back(v, w);
            graph[v].emplace_back(u, w);
        }

        double dist[N][K][2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= k; j++) {
                dist[i][j][0] = dist[i][j][1] = INF;
            }
        }

        priority_queue<tuple<double, int, int, int>, vector<tuple<double, int, int, int>>, greater<>> pq;
        dist[0][k][0] = 0.0;
        pq.emplace(0.0, 0, k, 0);

        double ans = INF;

        while (!pq.empty()) {
            auto [d, u, r, used] = pq.top();
            pq.pop();
            if (d > dist[u][r][used] + EPS) continue;

            if (u == n - 1) {
                ans = min(ans, d);
            }

            if (used == 0 && type[u] == 1 && r > 0) {
                if (d < dist[u][r-1][1] - EPS) {
                    dist[u][r-1][1] = d;
                    pq.emplace(d, u, r-1, 1);
                }
            }

            for (auto [v, w] : graph[u]) {
                double nd = d + (used == 0 ? (double)w : (double)w / 2.0);
                if (nd < dist[v][r][0] - EPS) {
                    dist[v][r][0] = nd;
                    pq.emplace(nd, v, r, 0);
                }
            }
        }

        if (ans == INF) {
            cout << "-1\n";
        } else {
            cout << fixed << setprecision(10) << ans << '\n';
        }
    }
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccUWApcX.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdyO4Mk.o:cyberland.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccUWApcX.o: in function `main':
grader.cpp:(.text.startup+0x71e): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status