Submission #1253941

#TimeUsernameProblemLanguageResultExecution timeMemory
1253941anfiCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
const double inf = 1e18;

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
    double ans = 1e18;
    K = min(K, 100);
    vector<pair<int,int>> adj[N];
    vector<double> dp(N, inf),tmp(N, inf);
    for(int i = 0;i < M; i++){
        adj[x[i]].push_back({y[i], c[i]});
        adj[y[i]].push_back({x[i], c[i]});
    }
    priority_queue<pair<double, int>> pq;
    for(int i = 0; i <= K; i++){
        vector<double> tmp(N, inf);
        if(i){
            for(int j = 0; j < N; j++){
                if(arr[j] == 1 || dp[j] == inf) continue;
                if(arr[j] == 0) tmp[j] = 0.0;
                pq.push({-dp[j]/2.0, j});
            }
        }else pq.push({0.0, 0});

        while(!pq.empty()){
            auto [c, u] = pq.top(); pq.pop();
            c = -c;
            if(u == H) continue;
            for(auto &[v, w] : adj[u]){
                if(tmp[v] > c+w){
                    if(arr[v] == 0) tmp[v] = 0.0;
                    else tmp[v] = cost;
                    pq.push({-tmp[v], v});
                }          
            }
        }
        ans = min(ans, tmp[H]);
        if(i == 0 && tmp[H]== inf) break;
        swap(tmp, dp);
    }
    return (ans >= inf/2 ? -1.0 :ans);
}

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:34:35: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   34 |                     else tmp[v] = cost;
      |                                   ^~~~
      |                                   cosl