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>
#define pb push_back
using namespace std;
const int n = 1e5+5;
vector<vector<pair<int, int>>> adj(n);
vector<bool> visited(n, false);
double dfs(int x, int h, int s){
if(x == h){return s;}
for(auto i : adj[x]){
if(!visited[i.first]){
visited[i.first] = true;
return dfs(i.first, h, s+i.second);
}
}
}
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
visited.clear();
visited.resize(n, false);
adj.clear();
visited[0] = true;
for(int i =0; i < M; i ++){
adj[x[i]].pb({y[i], c[i]});
adj[y[i]].pb({x[i], c[i]});
}
return dfs(0, H, 0);
}
Compilation message (stderr)
cyberland.cpp: In function 'double dfs(int, int, int)':
cyberland.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
18 | }
| ^
# | 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... |