Submission #983160

#TimeUsernameProblemLanguageResultExecution timeMemory
983160abushbandit_Cyberland (APIO23_cyberland)C++17
20 / 100
1027 ms2097152 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> a) { const double INF = DBL_MAX; vector<vector<pair<int,double>>> g(n); for(int i = 0;i < m;i++){ g[x[i]].pb({y[i],c[i]}); g[y[i]].pb({x[i],c[i]}); } set<tuple<double,int,int>> q; q.insert({0,0,k}); double dis[n][k + 1]; for(int i = 0;i < n;i++){ for(int j = 0;j <= k;j++){ dis[i][j] = INF; } } dis[0][k] = 0; while(!q.empty()){ auto [cost,v,nk] = *q.begin();q.erase(*q.begin()); if(dis[v][nk] < cost) continue; if(v == h) return cost; for(auto [to,w] : g[v]){ double newtime = cost + w; if(a[to] == 0) newtime = 0; if(newtime < dis[to][nk]){ dis[to][nk] = newtime; q.insert({newtime,to,nk}); } if(a[to] == 2 && nk > 0){ double time = newtime / 2; if(time < dis[to][nk - 1]){ dis[to][nk - 1] = time; q.insert({time,to,nk - 1}); } } } } return -1; }
#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...