Submission #1142852

#TimeUsernameProblemLanguageResultExecution timeMemory
1142852vladiliusCyberland (APIO23_cyberland)C++20
100 / 100
1261 ms67516 KiB
#include <bits/stdc++.h> 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<int, double, 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, 0, 1}); while (!pq.empty()){ node f = pq.top(); pq.pop(); auto [x, d, v] = f; if (v == h) continue; for (auto [u, w]: g[v]){ if (arr[u] == 0){ if (dp[u][x] > 0){ dp[u][x] = 0; pq.push({x, 0, u}); } } else if (arr[u] == 1){ double dist = d + w; if (dist < dp[u][x]){ dp[u][x] = dist; pq.push({x, dist, u}); } } else if (arr[u] == 2){ double dist = d + w; if (dist < dp[u][x]){ dp[u][x] = dist; pq.push({x, dist, u}); } dist /= 2; if (x < k && dist < dp[u][x + 1]){ dp[u][x + 1] = dist; pq.push({x + 1, dist, u}); } } } } double out = inf; for (int i = 0; i <= k; i++){ out = min(out, dp[h][i]); } return (out == inf) ? -1 : out; }
#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...