![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树的直径~最长路
文章平均质量分 81
idealistic
编程渣渣~~
展开
-
【light oj】树的直径
Farthest Nodes in a TreeTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionGiven a tree (a connected graph with no cycles), you have to原创 2016-08-02 15:29:48 · 287 阅读 · 0 评论 -
【POJ1985】Cow Marathon(基础 树的直径)
Cow MarathonTime Limit:2000MS Memory Limit:30000KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionAfter hearing about the epidemic of obesity in the USA, Farmer John原创 2016-08-02 11:42:49 · 320 阅读 · 0 评论 -
【poj2631】Roads in the North
Roads in the NorthTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionBuilding and maintaining roads among communities in the far No原创 2016-08-02 19:08:43 · 418 阅读 · 0 评论 -
树的直径模板~~最长路径
两次bfs:①任意从一个点u出发bfs,设其能到的最远点为v②从v出发重新bfs,设其能到达的最远点为s③则树的直径就是v->s证明:若能证明从任意一个点出发,bfs到的最远点一定在树的直径的端点上,那么第二次bfs就可以证明一定正确了,下面来证明第一次bfs正确性:①若选择的点u在直径上,那么能到的最远点v一定是树的直径的端点之一反证:若v不是树的直径的端点,原创 2016-08-02 17:30:18 · 816 阅读 · 0 评论 -
【POJ1383】BFS,迷宫,最长路
LabyrinthTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionThe northern part of the Pyramid contains a very large and complicated原创 2016-08-02 20:38:29 · 1210 阅读 · 0 评论