#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
const int N=1e5+5;
vector<pair<int,int>> g[N];
int used[N];
int D,f,ans;
void dfs(int x, int p, int y, int d){
used[x]=1;
if(d>D){
f=x;
D=d;
}
for(auto it: g[x]){
if(it.fr==p) continue;
dfs(it.fr,x,y,d+it.sc);
}
}
int get(int x, int y, int p, int D, int d){
if(x==y){
ans=min(ans,max(D,d));
return 1;
}
for(auto it: g[x]){
if(it.fr==p) continue;
if(get(it.fr,y,x,D-it.sc,d+it.sc)){
ans=min(ans,max(D,d));
return 1;
}
}
return 0;
}
int find(int x){
D=0,f=x;
dfs(x,x,-1,0);
D=0;
int F=f;
dfs(f,f,-1,0);
ans=1e9;
get(f,F,-1,D,0);
return ans;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
for(int i=0;i<M;i++){
g[A[i]].push_back({B[i],T[i]});
g[B[i]].push_back({A[i],T[i]});
}
vector<int> vec;
for(int i=0;i<N;i++){
if(!used[i]){
int c=find(i);
vec.push_back(c);
}
}
sort(vec.rbegin(),vec.rend());
int ans=vec[0];
if(vec.size()>1)
ans=max(ans,vec[0]+vec[1]+L);
if(vec.size()>2)
ans=max(ans,vec[1]+vec[2]+L+L);
return ans;
}
/*int main(){
int n,m,l;cin>>n>>m>>l;
int a[m]{},b[m]{},t[m]{};
for(int i=0;i<m;i++){
cin>>a[i]>>b[i]>>t[i];
}
cout<<travelTime(n,m,l,a,b,t);
}*/
Compilation message
dreaming.cpp:1:10: fatal error: grader.h: No such file or directory
1 | #include "grader.h"
| ^~~~~~~~~~
compilation terminated.