Submission #775907

# Submission time Handle Problem Language Result Execution time Memory
775907 2023-07-07T06:45:29 Z Sharky Cyberland (APIO23_cyberland) C++17
15 / 100
1075 ms 23996 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long

const double INF = 1E18;

struct node {
    double di;
    int u, k;
    bool operator > (const node& o) const {
        return di < o.di;
    }
};

double solve(int32_t N, int32_t M, int32_t K, int32_t H, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> c, std::vector<int32_t> arr) {
    K = min(K, 90);
    vector<pair<int, int>> adj[N];
    vector<vector<double>> d(N, vector<double> (K + 1, INF));
    for (int i = 0; i < M; i++) {
        if (x[i] != H) adj[x[i]].push_back({y[i], c[i]});
        if (y[i] != H) adj[y[i]].push_back({x[i], c[i]});
    }
    using T = node;
    priority_queue<T, vector<T>, greater<T>> pq;
    pq.push({0.0, 0, 0});
    d[0][0] = 0.0;
    for (int i = 0; i < N; i++) if (arr[i] == 0) {
        pq.push({0.0, i, 0});
        d[i][0] = 0.0;
    }
    while (!pq.empty()) {
        auto [di, u, k] = pq.top();
        pq.pop();
        if (di != d[u][k]) continue;
        for (auto& [v, w] : adj[u]) {
            if (arr[v] == 0) continue;
            double new_weight = d[u][k] + w;
            if (d[v][k] > new_weight) {
                d[v][k] = new_weight;
                pq.push((node) {d[v][k], v, k});
            }
            if (arr[v] == 2) {
                new_weight /= 2.0;
                if (d[v][k + 1] > new_weight) {
                    d[v][k + 1] = new_weight;
                    pq.push((node) {d[v][k + 1], v, k});
                }
            }
        }
    }
    // for (int i = 0; i <= H; i++) {
    //     for (int j = 0; j <= K; j++) {
    //         cout << i << " " << j << " ";
    //         cout << fixed << setprecision(6) << d[i][j] << "\n";
    //     }
    // }
    double res = *min_element(d[H].begin(), d[H].end());
    if (res == INF) return -1;
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 532 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1060 KB Correct.
2 Correct 24 ms 1640 KB Correct.
3 Correct 23 ms 1528 KB Correct.
4 Correct 26 ms 1492 KB Correct.
5 Correct 24 ms 1540 KB Correct.
6 Correct 20 ms 4796 KB Correct.
7 Correct 26 ms 4888 KB Correct.
8 Correct 13 ms 8044 KB Correct.
9 Correct 23 ms 1108 KB Correct.
10 Correct 25 ms 1176 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1504 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 23996 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 114 ms 1528 KB Correct.
2 Correct 116 ms 1528 KB Correct.
3 Correct 121 ms 1584 KB Correct.
4 Correct 1075 ms 4712 KB Correct.
5 Correct 25 ms 1108 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1568 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 1644 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 1852 KB Wrong Answer.
2 Halted 0 ms 0 KB -