제출 #1253940

#제출 시각아이디문제언어결과실행 시간메모리
1253940anfiCyberland (APIO23_cyberland)C++20
15 / 100
260 ms7092 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]){ double cost = c+w; if(tmp[v] > cost){ if(arr[i] == 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); }
#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...