![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LCA
kalilili
双眼闭三年。
展开
-
HDU 5266 pog loves szh III (LAC)
问题描述pog在与szh玩游戏,首先pog在纸上画了一棵有根树,这里我们定义1为这棵树的根,然后szh在这棵树中选了若干个点,想让pog帮忙找找这些点的最近公共祖先在哪里,一个点为S的最近公共祖先当且仅当以该点为根的子树包含S中的所有点,且该点深度最大。然而,这个问题是十分困难的,出于szh对pog的爱,他决定只找编号连续的点,即l i ~r i 。输入描述若干组数据(不超原创 2015-07-07 20:25:07 · 983 阅读 · 0 评论 -
HDU 2586 How far away ? (初学LCA)
How far away ?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7739 Accepted Submission(s): 2769Problem DescriptionThere are n hou原创 2015-07-07 20:01:14 · 746 阅读 · 0 评论 -
Codeforces Round #143 (Div. 2) E. Cactus(LCA+无向图缩点)
E. Cactustime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA connected undirected graph is called a vertex c原创 2015-07-20 22:29:22 · 779 阅读 · 0 评论 -
HDU 5274 Dylans loves tree(LCA+dfs时间戳+成段更新 OR 树链剖分+单点更新)
Problem DescriptionDylans is given a tree with N nodes.All nodes have a value A[i].Nodes on tree is numbered by 1∼N.Then he is given Q questions like that:①0 x y:change node x′原创 2015-07-22 10:27:46 · 2542 阅读 · 0 评论 -
UVA 12487 Midnight Cowboy(LCA+大YY)(好题)
题目pdf:http://acm.bnu.edu.cn/v3/external/124/12487.pdf大致题意:一棵树,一个人从A节点出发,等可能的选任何一条边走,有两个节点B,C求这个人先到达B的概率思路:先说结论:只和A的距离有关,先到达B+先到达A的概率 = 1,然后根据距离分配一下就好。构造性证明:如果B-A-C在一条链上显然就是按距离分配概率,因为链上的支原创 2015-08-15 00:58:53 · 1109 阅读 · 0 评论