Submission #752992

#TimeUsernameProblemLanguageResultExecution timeMemory
752992MohamedFaresNebiliCyberland (APIO23_cyberland)C++17
44 / 100
3054 ms7800 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<double, pair<int, int>>; const ll M = 1000000000000000000; const double epsilon = 0.00000001; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { double d[n]; d[0] = 0; for(int l = 1; l < n; l++) d[l] = M; vector<pair<int, int>> adj[n]; for(int l = 0; l < m; l++) { adj[x[l]].push_back({y[l], c[l]}); adj[y[l]].push_back({x[l], c[l]}); } priority_queue<pi, vector<pi>, greater<pi>> pq; pq.push({0, {k, 0}}); while(!pq.empty()) { double w = pq.top().first; int u = pq.top().second.second; int t = pq.top().second.first; pq.pop(); for(auto v : adj[u]) { double D = w + v.second; if(arr[v.first] == 0) D = 0; if(d[v.first] > D) { d[v.first] = D; if(v.first != h) pq.push({d[v.first], {t, v.first}}); } if(arr[v.first] == 2) { for(int l = 1; l <= t; l++) { D /= 2.0; if(d[v.first] > D) { d[v.first] = D; if(v.first != h) pq.push({d[v.first], {t - l, v.first}}); } } } } } if(d[h] == M) return -1; return d[h]; return 0; }
#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...