摘要: 题意:给定一棵树,求每一个节点所能到达的最长路径的长度分析:以编号的i的节点为例(非根节点),最长的路径长度只有俩种可能,1)子树中存在最长路径;2)通过父节点的路径中存在最长路径所以,只有分别求出每一节点对应的那俩种路径取大最大值即可,当然,根节点只存在第一种可能View Code #include<iostream>#include<algorithm>#include<string>#include<vector>using namespace std;const int N = 10010;int n,dist[N],dp[N];stru 阅读全文
posted @ 2012-03-06 16:21 枕边梦 阅读(292) 评论(0) 推荐(0) 编辑