Submission #983342

#TimeUsernameProblemLanguageResultExecution timeMemory
983342vjudge1Cyberland (APIO23_cyberland)C++17
21 / 100
1192 ms2097152 KiB
#include "cyberland.h" #include <bits/stdc++.h> #define mk make_pair #define pb push_back #define vi vector <int> #define vd vector <double> #define paii pair<int, int> using namespace std; using tp = tuple<double, int, int>; const double eps = 1e-9; const double inf = 1e14; double solve(int n, int m, int k, int h, vi x, vi y, vi c, vi a) { vector<vd> d(n, vd(k + 1, inf)); vector<vector<paii>> g(n); for (int i = 0; i < m; i++) { g[x[i]].pb(mk(y[i], c[i])); g[y[i]].pb(mk(x[i], c[i])); } d[0][0] = 0; priority_queue<tp, vector<tp>, greater<tp>> pq; pq.push({0, 0, 0}); while (!pq.empty()) { auto [exp, who, used] = pq.top(); pq.pop(); if (d[who][used] - exp < -eps) { continue; } if (who == h) { continue; } for (auto [to, w] : g[who]) { if (a[to] == 1) { if (d[to][used] > exp + w) { d[to][used] = exp + w; pq.push({d[to][used], to, used}); } } else if (a[to] == w) { if (used < k - 1 && d[to][used + 1] > ((exp + (double) w) / 2)) { d[to][used + 1] = (exp + (double) w) / 2; pq.push({d[to][used + 1], to, used + 1}); } if (d[to][used] > exp + w) { d[to][used] = exp + w; pq.push({d[to][used], to, used}); } } else { if (d[to][used] > 0) { d[to][used] = 0; pq.push({0, to, used}); } } } } double cur = d[h][0]; for (int i = 0; i <= k; i++) { if (cur > d[h][i]) { cur = d[h][i]; } } return cur; }
#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...