#include<iostream>
#include<vector>
using namespace std;
vector<int> Vec[100005];
int Result;
void dfs(int Child,int Parent,int PathLength){
for(int i =0 ;i < Vec[Child].size();i ++){
if(Vec[Child][i] == Parent){
continue;
}
dfs(Vec[Child][i],Child,PathLength +1);
}
Result = max(Result,PathLength);
}
int main(){
int n;
scanf("%d",&n);
for(int i = 0;i < n;i ++){
int x,y;
scanf("%d%d",&x,&y);
Vec[x].push_back(y);
Vec[y].push_back(x);
}
Result = 0;
dfs(1,-1,0);
printf("%d\n",(n - 1) * 2 - Result);
return 0;
}
标签:--,PathLength,dfs,int,给定,Vec,Child,顶点,Result From: https://blog.51cto.com/u_13121994/5798377