
倍增
Cherry_0525
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【LCA倍增模板+详细解释倍增】 POJ - 1330 A - Nearest Common Ancestors
实现 我们设f[i][j]表示i节点的第2^j代祖先,这样f[i][0]就是i的父亲,而对于所有j>0,我们有 f[i][j] = f[f[i][j - 1]][j - 1] 怎么理解呢? i节点的第2^(j - 1)代祖先的2^(j - 1)祖先就是i的第2^j代祖先 所以我们用O(nlogn)的时间就预处理出了f[][]数组 void dfs(int u,int fa){ ...原创 2018-09-05 17:19:43 · 217 阅读 · 0 评论 -
【树上三点求最短路】ZOJ - 3195 E - Design the city
E - Design the city ZOJ - 3195 Cerror is the mayor of city HangZhou. As you may know, the traffic system of this city is so terrible, that there are traffic jams everywhere. Now, Cerror finds out th...原创 2018-09-09 17:10:22 · 229 阅读 · 0 评论 -
【LCA倍增求最近公共祖先距离】HDU - 2586 B - How far away ?
B - How far away ?HDU - 2586 There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A ...原创 2018-09-06 15:49:44 · 228 阅读 · 0 评论 -
【LCA倍增+并查集 多棵树】HDU - 2874 D - Connections between cities
D - Connections between cities HDU - 2874 After World War X, a lot of cities have been seriously damaged, and we need to rebuild those cities. However, some materials needed can only be produced in c...原创 2018-09-06 23:44:08 · 381 阅读 · 0 评论 -
【LCA倍增+第k大(暴力)】HDU - 3078 F - Network
F - Network HDU - 3078 The ALPC company is now working on his own network system, which is connecting all N ALPC department. To economize on spending, the backbone network has only one router for e...原创 2018-09-10 12:51:01 · 227 阅读 · 0 评论 -
【倍增+线性基】2013.「SCOI2016」幸运数字
#2013.「SCOI2016」幸运数字 内存限制:256 MiB时间限制:4000 ms标准输入输出 题目描述 A 国共有座城市,这些城市由 n-1 条道路相连,使得任意两座城市可以互达,且路径唯一。每座城市都有一个幸运数字,以纪念碑的形式矗立在这座城市的正中心,作为城市的象征。一些旅行者希望游览 A 国。旅行者计划乘飞机降落在号城市,沿着号城市到号城市之间那条唯一的路径游览,最终从...原创 2019-07-27 17:09:27 · 167 阅读 · 0 评论