제출 #1190194

#제출 시각아이디문제언어결과실행 시간메모리
1190194kiritoCyberland (APIO23_cyberland)C++20
68 / 100
1944 ms21808 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 110000; vector<pair<int, ll>> g[N]; ld dp[N], tdp[N]; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { k = min(k, 70); for (int i = 0; i < m; i++) { int u = x[i], v = y[i], w = c[i]; g[u].push_back({v, w}); g[v].push_back({u, w}); } g[h].clear(); for (int i = 0; i < n; i++) dp[i] = tdp[i] = -1; dp[0] = 0; ld ans = 1e18; for (int i = 0; i <= k; i++) { for (int j = 0; j < n; j++) { if (dp[j] == -1) continue; if (arr[j] == 0) dp[j] = 0; if (arr[j] == 2) dp[j] /= 2; } set<pair<int, ld>> st; for (int j = 0; j < n; j++) if (dp[j] != -1) for (auto [u, w] : g[j]) { ld ndp = dp[j] + w; if (tdp[u] != -1 && tdp[u] <= ndp) continue; st.erase({u, tdp[u]}); tdp[u] = ndp; st.insert({u, tdp[u]}); } while (!st.empty()) { int v = st.begin()->first; st.erase(st.begin()); for (auto [u, w] : g[v]) { ld ndp = tdp[v] + w; if (tdp[u] != -1 && tdp[u] <= ndp) continue; st.erase({u, tdp[u]}); tdp[u] = ndp; st.insert({u, tdp[u]}); } } for (int j = 0; j < n; j++) { dp[j] = tdp[j]; tdp[j] = -1; } if (dp[h] != -1) ans = min(ans, dp[h]); } for (int i = 0; i < n; i++) g[i].clear(); if (ans == 1e18) ans = -1; return 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...