Submission #990486

#TimeUsernameProblemLanguageResultExecution timeMemory
990486OAleksaCyberland (APIO23_cyberland)C++17
49 / 100
3089 ms76880 KiB
#include "cyberland.h" #include <bits/stdc++.h> #define f first #define s second using namespace std; //g++ cyberland.cpp cyberland.h stub.cpp const int N = 1e5 + 69; const long long inf = 1e18; vector<pair<int, int>> g[N]; double dis[N][33]; double solve(int n, int m, int k, int s, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { //reset for (int i = 0;i < n;i++) g[i].clear(); for (int i = 0;i < m;i++) { g[x[i]].push_back({y[i], c[i]}); g[y[i]].push_back({x[i], c[i]}); } for (int i = 0;i < n;i++) { for (int j = 0;j <= k;j++) dis[i][j] = inf; } priority_queue<tuple<double, int, int>> pq; pq.push({0, 0, 0}); while (!pq.empty()) { auto x = pq.top(); pq.pop(); int v, j; double d; tie(d, v, j) = x; d = abs(d); if (a[v] == 0) { for (int j = 0;j <= k;j++) dis[v][j] = 0; d = 0; } for (auto u : g[v]) { if (dis[u.f][j] > d + u.s) { dis[u.f][j] = d + u.s; if (u.f != s) pq.push({-dis[u.f][j], u.f, j}); } if (a[u.f] == 2) { if (j < k && dis[u.f][j + 1] > (d + u.s) / 2) { dis[u.f][j + 1] = (d + u.s) / 2; if (u.f != s) pq.push({-dis[u.f][j + 1], u.f, j + 1}); } } } } double ans = inf; for (int i = 0;i <= k;i++) ans = min(ans, dis[s][i]); if (ans == inf) 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...