#include "deliveries.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
const int MAXN = 1005;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi;
vector<pi>adj[MAXN];
int n;
#define int long long
int W[MAXN];
void init(int32_t N, std::vector<int32_t> U, std::vector<int32_t> V, std::vector<int32_t> T, std::vector<int32_t> W) {
n=N;
for(int i=0;i<n-1;i++){
adj[U[i]].push_back({V[i],T[i]});
adj[V[i]].push_back({U[i],T[i]});
}
for(int i=0;i<n;i++){
::W[i]=W[i];
}
W[0]++;
}
int sz[MAXN];
int res=0;
void dfs(int x, int p, int vcost){
sz[x]+=W[x];
for(auto v:adj[x])if(v.first!=p){
dfs(v.first,x,v.second);
sz[x]+=sz[v.first];
}
}
void get(int x, int p, int vcost){
for(auto v:adj[x])if(v.first!=p){
get(v.first,x,v.second);
}
res += vcost * 2 * min(sz[x],sz[0]-sz[x]);
}
int solve(){
memset(sz,0,sizeof sz);
res=0;
dfs(0,-1,0);
get(0,-1,0);
return res;
}
long long max_time(int S, int X) {
W[S]=X;
if(S==0){
W[S]++;
}
return solve();
}
Compilation message
/usr/bin/ld: /tmp/cc2p2IzJ.o: in function `main':
grader.cpp:(.text.startup+0x4c7): undefined reference to `max_time(int, int)'
collect2: error: ld returned 1 exit status