随笔分类 -  5.11.2.0 树的重心与直径

摘要:树的直径 树的直径有两种求法 1.两遍 dfs 法, 便于输出具体方案,但是无法处理负权边 2.DP 法,代码量少,可以处理负权边 cpp include include include include include include using namespace std; const int M 阅读全文
posted @ 2018-03-29 16:43 Mr_Wolfram 阅读(199) 评论(0) 推荐(0)
摘要:树的直径 树的直径求法: 1. 任取一点u,找到树上距u最远的点s 2. 找到树上距s点最远的点t,s t的距离即为所求 cpp include include include include include include include using namespace std; int init 阅读全文
posted @ 2018-02-06 11:06 Mr_Wolfram 阅读(116) 评论(0) 推荐(0)