#include #include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000000 struct tree_diameter{ const long long X = 1000000000000000000; pair> get(vector>> &E){ vector dis = bfs(E,0); long long maxi = -1; int ind = 0; for(int i=0;imaxi){ maxi=dis[i]; ind=i; } } dis = bfs(E,ind); maxi = -1; for(int i=0;imaxi){ maxi=dis[i]; ind=i; } } vector ret; ret.push_back(ind); while(dis[ind]!=0LL){ for(int i=0;i> get(vector> &E){ vector>> e(E.size(),vector>()); for(int i=0;i bfs(vector>> &E,int start){ vector dis(E.size(),X); dis[start] = 0LL; queue Q; Q.push(start); while(Q.size()!=0){ int u = Q.front(); Q.pop(); for(int i=0;i>N; vector> E(N,vector()); rep(i,N-1){ int a,b; cin>>a>>b; a--;b--; E[a].push_back(b); E[b].push_back(a); } tree_diameter T; int x = T.get(E).first; cout<