This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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, int left){
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, left-1);
dfs(h.node, cnt+h.cnt, node, left);
}
}
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, k);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |