#include <iostream> #include <cstring> using namespace std; const int N = 1e5 + 10; int h[N], e[2 * N], ne[2 * N], idx, n; int d[N]; int maxd[N]; void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } void dfs(int u, int fa) { for (int i = h[u]; i != -1; i = ne[i])...