
LCA
Cherry_0525
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【LCA离线算法Tarjan】POJ - 1330 D - Nearest Common Ancestors
D - Nearest Common Ancestors POJ - 1330 A rooted tree is a well-known data structure in computer science and engineering. An example is shown below: In the figure, each node is labeled with an inte...原创 2018-08-30 01:43:50 · 143 阅读 · 0 评论 -
【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 评论 -
【LCA+tarjan缩点+无向图含重边缩点板子】ZOJ Problem Set - 4097 Rescue the Princessing
Rescue the Princess Time Limit:1 Second Memory Limit:65536 KB Princess Cjb is caught by Heltion again! Her knights Little Sub and Little Potato are going to Heltion Kingdom to rescue her. He...原创 2019-04-17 20:05:36 · 263 阅读 · 0 评论