Submission #981854

#TimeUsernameProblemLanguageResultExecution timeMemory
981854FZ_MeloCyberland (APIO23_cyberland)C++17
8 / 100
1158 ms2097152 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; struct ari{ int node; double cnt; }; vector<vector<ari>> adj; int state[100000]; int n, m, k, fin; double ans; void dfs(int node, double cnt, int ant){ if(node==fin){ if(ans==(1<<30)) ans=cnt; else ans=min(ans, cnt); return; } for(auto h: adj[node]){ if(h.node==ant) continue; if(state[node]==0) dfs(h.node, h.cnt, node); else dfs(h.node, cnt+h.cnt, node); } } 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) { n=N; m=M; k=K; fin=H; adj.clear(); adj.resize(n); ans=(1<<30); for(int i=0; i<m; i++){ adj[x[i]].push_back({y[i], (double)c[i]}); adj[y[i]].push_back({x[i], (double)c[i]}); } for(int i=0; i<n; i++) state[i]=arr[i]; dfs(0, 0, 0); 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...