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