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;
typedef long long ll;
vector<vector<pair<int,int>>> al;
double ans;
void dfs(int i, int p, double c, vector<int> a) {
if (i==0) {
ans=min(ans,c);
return;
}
if (a[i]==0) {
ans=min(ans,c);
c=0;
}
for (auto v: al[i]) {
if (v.first==p) continue;
dfs(v.first,i,v.second+c,a);
}
}
double solve(int N, int M, int K, int H, vector<int> x, vector<int>
y, vector<int> c, vector<int> a) {
ans=1e9;
al.assign(N,vector<pair<int,int>>());
for (int i=0; i<M; i++) {
al[x[i]].push_back({y[i],(double)c[i]});
al[y[i]].push_back({x[i],(double)c[i]});
}
dfs(H,-1,0,a);
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... |