Submission #990672

# Submission time Handle Problem Language Result Execution time Memory
990672 2024-05-31T01:23:00 Z Ibrohim0704 Cyberland (APIO23_cyberland) C++17
15 / 100
801 ms 2648 KB
#include <vector>
#include <queue>
#include <algorithm>
 
using namespace std;
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    vector<double> min_time(N, numeric_limits<double>::infinity());
    min_time[0] = 0;
    
    auto cmp = [](const pair<double, int>& a, const pair<double, int>& b) {
        return a.first > b.first;
    };
 
    priority_queue<pair<double, int>, vector<pair<double, int>>, decltype(cmp)> pq(cmp);
    pq.push({0, 0});
 
    while (!pq.empty()) {
        double time = pq.top().first;
        long long int country = pq.top().second;
        pq.pop();
 
        if (country == H) {
            return time;
        }
 
        for (long long int i = 0; i < M; ++i) {
            long long int neighbor;
            if (x[i] == country) {
                neighbor = y[i];
            } else if (y[i] == country) {
                neighbor = x[i];
            } else {
                continue;
            }
 
            double neighbor_time = time + c[i];
 
            if (arr[neighbor] == 2 && K > 0) {
                neighbor_time /= 2;
                --K;
            }
 
            if (neighbor_time < min_time[neighbor]) {
                min_time[neighbor] = neighbor_time;
                pq.push({neighbor_time, neighbor});
            }
        }
    }
 
    return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 604 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 344 KB Correct.
2 Correct 32 ms 548 KB Correct.
3 Correct 30 ms 348 KB Correct.
4 Correct 33 ms 504 KB Correct.
5 Correct 32 ms 344 KB Correct.
6 Correct 63 ms 724 KB Correct.
7 Correct 175 ms 600 KB Correct.
8 Correct 305 ms 1112 KB Correct.
9 Correct 15 ms 344 KB Correct.
10 Correct 15 ms 344 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 508 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 801 ms 2648 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 348 KB Correct.
2 Correct 21 ms 520 KB Correct.
3 Correct 24 ms 348 KB Correct.
4 Correct 96 ms 624 KB Correct.
5 Correct 12 ms 348 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 344 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 344 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 276 ms 644 KB Wrong Answer.
2 Halted 0 ms 0 KB -