#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
#define node tuple<double, int, int>
const double inf = 1e15;
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
    vector<pii> g[n + 1];
    for (int i = 0; i < m; i++){
        x[i]++; y[i]++;
        g[x[i]].pb({y[i], c[i]});
        g[y[i]].pb({x[i], c[i]});
    }
    k = min(k, 70); // LOL 
    arr.insert(arr.begin(), 0); h++;
    
    vector<vector<double>> dp(n + 1, vector<double>(k + 1, inf));
    priority_queue<node, vector<node>, greater<node>> pq;
    dp[1][0] = 0; pq.push({0, 1, 0});
    for (int i = 1; i <= n; i++){
        if (!arr[i]){
            for (int j = 0; j <= k; j++){
                dp[i][j] = 0;
            }
            pq.push({0, i, 0});
        }
    }
    while (!pq.empty()){
        node f = pq.top(); pq.pop();
        auto [d, v, x] = f;
        if (v == h) continue;
        for (auto [u, w]: g[v]){
            if (arr[u] == 1){
                double dist = d + w;
                if (dist < dp[u][x]){
                    dp[u][x] = dist;
                    pq.push({dist, u, x});
                }
            }
            else if (arr[u] == 2){
                double dist = d + w;
                if (dist < dp[u][x]){
                    dp[u][x] = dist;
                    pq.push({dist, u, x});
                }
                dist /= 2;
                if (x < k && dist < dp[u][x + 1]){
                    dp[u][x + 1] = dist;
                    pq.push({dist, u, x + 1});
                }
            }
        }
    }
    double out = inf;
    for (int i = 0; i <= k; i++){
        out = min(out, dp[h][i]);
    }
    return (out == inf) ? -1 : out;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |