Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <stdio.h>#include <string.h>#include <vector>using namespace std;const int N = 100003;bool used[N];vector<int> cmap[N];int max_high, max_root;int high[N];int n;void dfs(int root, int cur_high){used[root] = true;if(cur_high > max_high){max_high = cur_high;max_root = root;}for(vector<int>::iterator ite = cmap[root].begin(); ite != cmap[root].end(); ++ite){if(!used[*ite]){used[*ite] = true;dfs(*ite, cur_high + 1);}}}int main(){while(~scanf("%d", &n)){for(int i = 0; i < n - 1; i++){int from, to;scanf("%d%d", &from, &to);