YunYan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  树论---LCA

摘要:题目大意:一棵树,然后m个询问,每个询问有k个点,然后判断是否有一条路,要求这k个点要么在这条路上,要么和这条路相距为1. 题解:刚开始的思路是这样的,这条路的终点肯定是深度最深的那个点,然后用BFS找到从1到终点的路线,然后在对路径上的点和与路径直接相连的点进行判断,看这k个点是否都在其中,然后就 阅读全文
posted @ 2020-05-08 11:50 Target--fly 阅读(169) 评论(0) 推荐(0)

摘要: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 阅读全文
posted @ 2019-08-08 19:29 Target--fly 阅读(215) 评论(0) 推荐(0)

摘要: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 阅读全文
posted @ 2019-08-08 19:27 Target--fly 阅读(131) 评论(0) 推荐(0)

摘要:Language: Default Closest Common Ancestors Time Limit: 2000MS Memory Limit: 10000K Total Submissions: 24653 Accepted: 7648 Description Write a program 阅读全文
posted @ 2019-08-08 17:39 Target--fly 阅读(124) 评论(0) 推荐(0)

摘要:例题:http://poj.org/problem?id=1986 POJ1986 Distance Queries Language: Default Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total Submission 阅读全文
posted @ 2019-08-08 16:49 Target--fly 阅读(308) 评论(0) 推荐(0)

摘要:https://www.luogu.org/problemnew/solution/P3379 LCA叫做最短公共祖先,用来求距离树上两个节点最近的公共点; 常用倍增算法: 阅读全文
posted @ 2019-08-08 16:46 Target--fly 阅读(311) 评论(0) 推荐(0)