摘要: #include using namespace std; const int maxn=450005; struct node{ int nxt; int to; }tree[maxn*2]; struct node1{ int LCA; int nxt; int to; }qtree[maxn*2]; int fa[maxn]; int n,m,p,x... 阅读全文
posted @ 2019-06-13 16:39 JBLee 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 树的直径的定义: 对于求树的直径,我们有两种方法,使用两次dfs遍历和bfs遍历。 我选用的是dfs遍历,两次dfs遍历。 第一次:任选一个节点,找到最长路的节点去。 第二次:以刚刚走到的那个节点为原点,再跑一遍最长路。 某位Dalao博客中对于其的证明 阅读全文
posted @ 2019-06-13 14:19 JBLee 阅读(147) 评论(0) 推荐(0) 编辑