摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2196题意:在一个每条边都有权值的树中,求每个顶点能走的最大距离;思路:两次dfs,以1为根结点,一次从叶子到根结点,求出最远距离和次远距离。另一次从根进行dfs.(res[]为经过父节点能走最长距离)代码:View Code #include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <vector>#define sum 10010using 阅读全文
posted @ 2012-02-21 21:56 LT-blogs 阅读(143) 评论(0) 推荐(0) 编辑