#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pf push_front
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
const int MAX = 2001;
vector<pi> g[MAX];
bool is[MAX];
ll ans = 0;
void dfs(int from , int p, ll dis){
// cout << from << " " <<dis <<endl;
if(g[from].size()==1){
ans = max(ans,dis);
return;
}
for(pi to : g[from]){
if(to.f==p)continue;
dfs(to.f,from,dis+to.s);
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
for(int i = 0; i< M; i++){
int a = R[i][0];
int b = R[i][1];
g[a].pb({b,L[i]});
g[b].pb({a,L[i]});
}
dfs(0,-1,0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |