
树分治
Error Man
我是菜逼
展开
-
SPOJ QTREE4 Query on a tree V (边分治 + 分治结构)
题目连接 题意: 一个树,n 个结点,初始时全部为黑色。 有修改操作:将一个点的颜色反转,黑 -> 白,白 -> 黑 查询操作:给一个点 v,询问 v 与一个白色点 u 的最近距离,其中 u 可以等于 v Analyse: 和 Query on a tree IV 差不多。以中心边的 u 和 v 分别为当前子树的根结点进行 dfs,维护每个点将属于的连通块编号以及这个点到当前连通块根...原创 2019-11-10 13:44:32 · 253 阅读 · 0 评论 -
点、边分治总结
文章目录点分治与边分治相同之处:不同之处:关于复杂度:推荐题目: 点分治与边分治相同之处: 每一次都找树重心(中心边),将所有的路径都分成是否经过树重心(中心边),假设经过为情况1,未经过为 情况2,那么树分治也就是处理完情况1后,递归分治 (情况2) 对情况1: 需要做的就是处理所有点到树重心(或者中心边的 u,v) 如距离,复杂度 O(当前连通块大小)。。。。最好还是写几个题,能够理解更深 ...原创 2019-11-05 10:58:18 · 747 阅读 · 0 评论 -
SPOJ QTREE4 Query on a tree IV (边分治 + 用堆维护分治结构)
题目连接 题意: 给定一棵树,节点有黑白两种颜色,有正负的边权。 有两种操作: 一种是修改反转某个节点的颜色; 另一种是询问树上最远的两个白色节点的距离。 Analyse: 边分治,和点分治类似,每次找的中心边 (删除这一条边之后形成的两颗子树的 size 的最大值尽量小) . 假设中心边是 x-y ,那么和点分治差不多,将所有边分为经过 x-y 边与不经过 x-y 边,然后递归分治处理。 需要一...原创 2019-11-04 23:56:29 · 270 阅读 · 0 评论 -
HDU - 4670 (点分治 + 状压 + map(卡unordered_map))
Cube number on a tree The country Tom living in is famous for traveling. Every year, many tourists from all over the world have interests in traveling there. There are n provinces in the country. Acco...原创 2019-10-22 23:03:43 · 243 阅读 · 0 评论 -
HDU 4871 Shortest-path tree(最短路 + 点分治,大致参考 hdu 4812)
Shortest-path tree Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 130712/130712 K (Java/Others) Total Submission(s): 2408 Accepted Submission(s): 821 Problem Description Given a connected,...原创 2019-10-13 22:13:59 · 346 阅读 · 0 评论 -
HDU 4812 D Tree (点分治,技巧去同一子树的贡献)
D Tree Problem Description There is a skyscraping tree standing on the playground of Nanjing University of Science and Technology. On each branch of the tree is an integer (The tree can be treated as ...原创 2019-10-12 12:52:36 · 234 阅读 · 0 评论 -
POJ 1741 Tree (树的点分治简单题)
Tree Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is ...原创 2019-10-09 20:42:47 · 446 阅读 · 0 评论 -
POJ 2114 Boatherds (树的点分治简单题)
Boatherds Boatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers originate somewhere in the mountains and on their wa...原创 2019-10-10 22:19:36 · 316 阅读 · 0 评论