#include //#include //using namespace atcoder; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define pii pair #define pll pair #define rep(i,num,n) for(int i=num;i<(int)(n);i++) //for_loop #define REP(i,n) for(int i=0;i<(int)(n);i++) #define rrep(i,num,n) for(int i=num-1;i>=(int)(n);i--) //reverse_for> #define in(x,a,b) (a<=x && xb){a=b;return true;}return false;} bool chmax(ll &a,ll b){if(ab){a=b;return true;}return false;} bool chmax(int &a,int b){if(a>n; vector>g(n); rep(i,1,n){ int a,b; cin>>a>>b; a--,b--; g[a].push_back(b); g[b].push_back(a); } vectorused(n,false),used2(n,false); used[0]=used2[0]=true; vector>dp(2,vector(n,-INFI)); rep(i,0,n)dp[0][i]=INFI; //木DP auto dfs=[&](auto f,int pos)->int{ bool leaf=false; int mi=INFI,ma=-INFI; for(auto to:g[pos]){ if(used[to])continue; used[to]=true; leaf=true; f(f,to);//再帰 chmin(dp[0][pos],dp[1][to]+1); chmax(dp[1][pos],dp[0][to]+1); } //ボトムケース if(!leaf){ dp[0][pos]=dp[1][pos]=0; } return 0; }; dfs(dfs,0); cout<