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"
#include "crocodile.h"
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
void dfs(vector<pair<int, int>> tree[], vector<int> &dist, int u, int e)
{
for(auto v: tree[u])
{
if(v.fi==e)
continue;
dist[v.fi] = dist[u] + v.se;
dfs(tree, dist, v.fi, u);
}
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
vector<pair<int, int>> tree[n];
for(int i = 0; i<m; i++)
{
tree[r[i][0]].pb(mp(r[i][1], l[i]));
tree[r[i][1]].pb(mp(r[i][0], l[i]));
}
vector<int> dist(n, 0);
dfs(tree, dist, 0, -1);
int maxi = 0;
for(int i = 0; i<n; i++)
{
maxi = max(maxi, dist[i]);
}
return maxi;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |