Submission #990674

# Submission time Handle Problem Language Result Execution time Memory
990674 2024-05-31T01:27:08 Z Ibrohim0704 Cyberland (APIO23_cyberland) C++17
0 / 100
924 ms 2264 KB
#include <iostream>
#include <vector>
#include <queue>
#include <limits>

using namespace std;

struct Node {
    int country;
    int passingTime;

    Node(int c, int t) : country(c), passingTime(t) {}
    bool operator>(const Node& other) const {
        return passingTime > other.passingTime;
    }
};

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    vector<bool> visited(N, false);

    pq.push(Node(0, 0));

    while (!pq.empty()) {
        Node current = pq.top();
        pq.pop();
        if (current.country == H) {
            return current.passingTime;
        }
        visited[current.country] = true;
        for (int i = 0; i < M; ++i) {
            int neighbor;
            int roadTime;
            if (x[i] == current.country) {
                neighbor = y[i];
                roadTime = c[i];
            } else if (y[i] == current.country) {
                neighbor = x[i];
                roadTime = c[i];
            } else {
                continue;
            }

            int passingTime = current.passingTime + roadTime;
            if (arr[neighbor] == 2 && K > 0) {
                passingTime /= 2;
                K--; 
            } else if (arr[neighbor] == 0) {
                passingTime = 0;
            }

            if (!visited[neighbor]) {
                pq.push(Node(neighbor, passingTime));
            }
        }
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 616 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 348 KB Double -1.40446e+09 violates the range [-1, 1e+18]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 480 KB Double -2.12228e+09 violates the range [-1, 1e+18]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 924 ms 2264 KB Double -1.97863e+09 violates the range [-1, 1e+18]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 348 KB Double -4.06878e+08 violates the range [-1, 1e+18]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 520 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 348 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 348 KB Wrong Answer.
2 Halted 0 ms 0 KB -