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 <bits/stdc++.h>
using namespace std;
#define F first
#define S second
using ll = long long;
vector<vector<pair<int, int>>> adj;
int dfs(int k, int p, int &H)
{
if (k == H)
return 1;
for (pair<int, int> i : adj[k])
if (i.F != p)
{
int x = dfs(i.F, k, H);
if (x > 0)
return x + i.S;
}
return 0;
}
double solve(int N, int M, int H, int K, vector<int> x, vector<int> y, vector<int> c, vector<int> arr)
{
adj.resize(N);
for (int i = 0; i < M; i++)
{
adj[x[i]].emplace_back(y[i], c[i]);
adj[y[i]].emplace_back(x[i], c[i]);
}
return double(dfs(0, 0, H) - 1);
}
# | 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... |