码迷,mamicode.com
首页 >  
搜索关键字:树上点分治    ( 18个结果
HDU 4812 D Tree (树上点分治)
题目地址:HDU 4812 这题是13年南京区域赛的现场题。 树分治思想。 树分治的过程中记录下每个子树的所有到达根的路径的积,用best记录下每个积的最小端点,然后再枚举当前子树的每个积,然后用逆元的方法求出当积为k时所需要的另一个端点值,并更新答案。 代码如下:#include #include #include #inclu...
分类:其他好文   时间:2015-07-11 12:13:45    阅读次数:568
SPOJ 1825 FTOUR2 - Free tour II (树上点分治)
题目地址:SPOJ 1825 树分治的题果然除了模板题就是金牌题啊。。。这题是一道论文题,想了好长时间。。。。终于过了,,,,注意一个坑点,如果权值全部为负的话,是可以不选任意一条边的,这样权值为0。。。也就是说初始值要设为0。。。 具体看漆子超的论文《分治算法在树的路径问题中的应用》。。 代码如下:#include #include #includ...
分类:其他好文   时间:2015-07-10 16:42:27    阅读次数:189
BZOJ 2152 聪聪可可 (树上点分治)
题目地址:BZOJ 2152 找有多少对权值和为3的倍数的点。最简单的点分治。 代码如下:#include #include #include #include #include #include #include #include #include...
分类:其他好文   时间:2015-06-30 00:06:10    阅读次数:133
POJ 2114 Boatherds (树上点分治)
题目地址:POJ 2114 点分治水题。只是把距离小于等于k改成了等于k。稍微加一点处理就可以了。 代码如下:#include #include #include #include #include #include #include #include <set...
分类:其他好文   时间:2015-06-29 22:21:07    阅读次数:154
POJ 1987 Distance Statistics (树上点分治)
题目地址:POJ 1987 点分治模板题,跟POJ 1741几乎一样,。。 代码如下:#include #include #include #include #include #include #include #include #include <...
分类:其他好文   时间:2015-06-27 22:53:36    阅读次数:137
POJ 1741 Tree (树上点分治)(楼教主男人八题之一)
题目地址:POJ 1741 树分治第一发! 树分治详情请看漆子超的国家集训队论文,论文传送门 树分治裸题。 代码如下:#include #include #include #include #include #include #include #includ...
分类:其他好文   时间:2015-06-26 12:54:09    阅读次数:160
POJ1741Tree(树上点分治)
Tree Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13091   Accepted: 4205 Description Give a tree with n vertices,each edge has a length(positive integer l...
分类:其他好文   时间:2015-06-21 19:50:45    阅读次数:116
树上点分治学习记录
跟着机房的潮流学了点分治,发现这个东西其实还蛮好写的,学会思想,很容易YY出来。直接上习题。 POJ 1741 TREE 点分治的模板题,首先设点xx到当前子树跟rootroot的距离为gxg_x,则满足gx+gy≤kg_x+g_y \le k可以加进答案,但是注意如果x,yx,y在同一棵子树中,就要删去对答案的贡献,以为x,yx,y会在其所在的子树中在计算一次。注意无根树转有根树的过程,需要选...
分类:其他好文   时间:2015-06-17 21:40:08    阅读次数:172
18条   上一页 1 2
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!