#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
vector<pair<long long int, long long int> > graph[N];
bool vis[N];
long long int mx = 0;
void dfs(int source, long long int largest){
vis[source] = 1;
mx = max(mx, largest);
for(auto k : graph[source])
if(!vis[k.first])
dfs(k.first, largest + k.second);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]){
for(int i = 0; i < M; ++i){
long long int u = A[i], v = B[i], c = T[i];
graph[u].push_back({v, c});
graph[v].push_back({u, c});
// cout << u << ' ' << v << ' ' << c << endl;
}
vector<long long int> diameters;
for(int i = 0; i < N; ++i){
if(!vis[i]){
mx = 0;
dfs(i, 0);
cout << mx << '\n';
diameters.push_back(mx);
}
}
long long int ans = 0;
for(auto k : diameters)
ans = max(ans, k);
return (ans + (L * (N - M - 1)));
}
Compilation message
/tmp/cc857M9T.o: In function `main':
grader.c:(.text.startup+0xc9): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status