摘要: 树的直径是求一棵树最远的两点之间的距离。 套路:两次dfs,一次dfs求离根最远的结点A,再以A为根搜索离A最远的结点B,A到B就是树的直径(双向的树) #include<bits/stdc++.h> using namespace std; const int N=100010; int n; s 阅读全文
posted @ 2022-01-28 17:42 秋月桐 阅读(49) 评论(0) 推荐(0) 编辑