树的直径
c_3Po_
这个作者很懒,什么都没留下…
展开
-
牛客练习赛40
题目链接C题 小A与欧拉路先考虑回路的情况。由于是一棵树,任两点间路径只有一条,从一条边走到深度更大的点,一定还会从同一条边返回以回到起点或者遍历其他子树,所以每条边需要复制一次,此时答案是边权和的两倍。不是回路的情况可以减掉从终点回到起点的路径,要让这条路径尽量长,所以长度一定是直径的长度。答案就是边权和的两倍减去直径长度。#include <bits/stdc++....原创 2019-02-16 11:58:00 · 555 阅读 · 0 评论 -
POJ - 2631 Roads in the North ( 求树的直径)
题目链接Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that there is only one route from a village to a village t...原创 2019-04-18 22:14:55 · 116 阅读 · 1 评论