Submission #845554

#TimeUsernameProblemLanguageResultExecution timeMemory
845554veehjCyberland (APIO23_cyberland)C++17
0 / 100
3058 ms2097156 KiB
#include "cyberland.h" #include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define F first #define S second #define pb push_back #define sz(a) (int)a.size() #define all(x) (x).begin(), (x).end() vector<vector<ld>> dist; vector<vector<pair<int, int>>> adj; vector<int> a; const ld inf = 1e15+9; ld ans=inf; void go(int nw, int h, int remain, ld curr){ if(dist[nw][remain]<=curr) return; dist[nw][remain]=curr; if(nw==h) return; for(auto& u : adj[nw]){ ld nw_curr=curr; if(a[nw]==0) nw_curr=0; go(u.F, h, remain, nw_curr+u.S); if(a[nw]==2 && remain>0){ nw_curr/=2.0; go(u.F, h, remain-1, nw_curr+u.S); } } } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { a=arr; dist.assign(N, vector<ld>(K+1, inf)); adj.resize(N); for(int i=0; i<M; i++){ adj[x[i]].pb({y[i], c[i]}); adj[y[i]].pb({x[i], c[i]}); } go(0, H, K, 0); for(int i=0; i<=K; i++) ans=min(ans, dist[H][i]); if(ans==inf) return -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...