Submission #920301

#TimeUsernameProblemLanguageResultExecution timeMemory
920301NotLinuxCyberland (APIO23_cyberland)C++17
100 / 100
852 ms10828 KiB
#include "cyberland.h" #include<bits/stdc++.h> using namespace std; const double INF = 1e18; struct Data{ int u; double w; Data(int _u, double _w) : u(_u), w(_w) {} friend bool operator <(Data a, Data b){ return a.w > b.w; } }; double solve(int n, int m, int k, int h, vector<int>x, vector<int>y, vector<int>c, vector<int>arr) { vector<vector<pair<int, int>>>e(n); for(int i = 0; i < m; i++){ e[x[i]].emplace_back(y[i], c[i]); e[y[i]].emplace_back(x[i], c[i]); } priority_queue<Data>q; vector<double>d(n, INF); q.emplace(0, d[0] = 0.0); double ans = INF; for(int i = min(k, 80); i > -1; i--){ vector<double>D(n, INF); priority_queue<Data>Q; while(!q.empty()){ auto [u, w] = q.top(); q.pop(); if(w > d[u] || u == h){ continue; } for(auto& [v, weight] : e[u]){ if(arr[v] == 0){ if(d[v] > 0.0){ q.emplace(v, d[v] = 0.0); } } else{ double W = w + double(weight); if(W < d[v]){ q.emplace(v, d[v] = W); } if(arr[v] == 2 && i > 0 && (W /= 2.0) < D[v]){ Q.emplace(v, D[v] = W); } } } } if(ans > d[h])ans = d[h]; d = D; q = Q; } return ans == INF ? -1 : ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...