![](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 Tree Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Description Given a tree (a connected graph with no cycles), you have to原创 2016-08-02 15:29:48 · 294 阅读 · 0 评论 -
【POJ1985】Cow Marathon(基础 树的直径)
Cow Marathon Time Limit:2000MS Memory Limit:30000KB 64bit IO Format:%lld & %llu Submit Status Description After hearing about the epidemic of obesity in the USA, Farmer John原创 2016-08-02 11:42:49 · 322 阅读 · 0 评论 -
【poj2631】Roads in the North
Roads in the North Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Status Description Building and maintaining roads among communities in the far No原创 2016-08-02 19:08:43 · 427 阅读 · 0 评论 -
树的直径模板~~最长路径
两次bfs: ①任意从一个点u出发bfs,设其能到的最远点为v ②从v出发重新bfs,设其能到达的最远点为s ③则树的直径就是v->s 证明: 若能证明从任意一个点出发,bfs到的最远点一定在树的直径的端点上,那么第二次bfs就可以证明一定正确了,下面来证明第一次bfs正确性: ①若选择的点u在直径上,那么能到的最远点v一定是树的直径的端点之一 反证: 若v不是树的直径的端点,原创 2016-08-02 17:30:18 · 826 阅读 · 0 评论 -
【POJ1383】BFS,迷宫,最长路
Labyrinth Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Description The northern part of the Pyramid contains a very large and complicated原创 2016-08-02 20:38:29 · 1212 阅读 · 0 评论