Submission #990671

# Submission time Handle Problem Language Result Execution time Memory
990671 2024-05-31T01:22:20 Z Ibrohim0704 Cyberland (APIO23_cyberland) C++17
Compilation error
0 ms 0 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;
            }
 
            long long 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;
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:36:18: error: 'long long' specified with 'double'
   36 |             long long double neighbor_time = time + c[i];
      |                  ^~~~