Submission #749867

#TimeUsernameProblemLanguageResultExecution timeMemory
7498671neCyberland (APIO23_cyberland)C++17
44 / 100
3054 ms11272 KiB
#include "cyberland.h" #include <bits/stdc++.h> #include <vector> using namespace std; 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> arr) { vector<vector<pair<int,int>>>adj(N); for (int i = 0;i<M;++i){ adj[x[i]].push_back({y[i],c[i]}); adj[y[i]].push_back({x[i],c[i]}); } queue<pair<int,int>>q; q.push({0,0}); vector<vector<double>>dist(N,vector<double>(2,1e12)); dist[0][0] = 0; while(!q.empty()){ auto u = q.front(); q.pop(); if (u.first == H)continue; for (auto x:adj[u.first]){ long long v = x.second; if (arr[x.first] == 0){ v = -dist[u.first][u.second]; } if (dist[x.first][u.second] > dist[u.first][u.second] + v){ dist[x.first][u.second] = dist[u.first][u.second] + v; q.push({x.first,u.second}); } if (arr[x.first] == 2 && u.second == 0){ int vx = x.second; for (auto y:adj[x.first]){ vx = min(vx,y.second); } double nx = dist[u.first][u.second] + x.second; double nxmin = nx; int cnt = K; while(nx > 0 && cnt > 0){ nx/=2; nxmin = min(nxmin,nx); cnt--; nx+=2 * vx; } if (dist[x.first][1] > nxmin){ dist[x.first][1] = nxmin; q.push({x.first,1}); } //nx = dist[u.first][u.second] + x.second)/2 + 2 * vx) / 2 + 2 * vx ) / 2 } } } if (dist[H][0] == 1e12 && dist[H][1] == 1e12)return -1; return min(dist[H][0],dist[H][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...