码迷,mamicode.com
首页 >  
搜索关键字:树的直径    ( 435个结果
BZOJ 1912 巡逻(树直径)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1912题意:给出一棵树,边权为1。现在加一条或两条边后,使得从1出发遍历每个点至少一次再回到1的路程最短。思路:先求一次树的直径Max1。然后将直径的边权改为-1,再求一次直径Max2。答案...
分类:其他好文   时间:2014-06-23 06:33:15    阅读次数:171
[xyz模拟题]动态维护树的直径
专出神题的xyz。支持删加边、修改点权、维护树的直径。LCT 需要额外记录子树信息。用一个堆维护。#include#include#include#include#include#includeusing namespace std;#define rep(i,x,y) for(i=x;i=y;i....
分类:其他好文   时间:2014-05-17 14:29:38    阅读次数:667
UVa 10308 Roads in the North 树的直径
题目来源:UVa 10308 Roads in the North 题意:求距离最远的2点之间的距离 思路:裸的树的直径 或者树形DP #include #include #include using namespace std; const int maxn = 100010; struct node { int to, w; node(){} node(int to, int...
分类:其他好文   时间:2014-05-15 03:37:18    阅读次数:295
ZOJ 3684 Destroy 树的中心
中心节点就是树的中心,2遍dfs求到树的直径,而中心一定在直径上,顺着直径找到中心就够了。 然后可以一遍树形DP找到最小值或者二分+判断是否访问到叶子节点。 #include #include #include #include using namespace std; struct node { int next; int power; int length...
分类:其他好文   时间:2014-05-13 11:28:38    阅读次数:306
hdu 4607 Park Visit 求树的直径
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4607 题目大意:给你n个点,n-1条边,将图连成一棵生成树,问你从任意点为起点,走k(k 思路:树形dp求树的直径r;                 a:若k                 b:若k>=r+1,ans = r+(k-(r+1))*2; #include "stdi...
分类:其他好文   时间:2014-05-06 22:26:03    阅读次数:328
435条   上一页 1 ... 42 43 44
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!