
LCA&RMQ
文章平均质量分 91
JustSmilelee
相信自己,坚持,奋斗,加油!
展开
-
A - How far away ?
I - How far away ?这道题的意思是有n个房子和n-1条边,每两个房子之间只有一条路径,询问从u到v之间的最短路径,既需要寻找到这两个点的最近的祖先,然后通过最近的祖先到达,这条路即为最短路。LCA&RMQ,LCA是在一棵树中寻找两点的最近祖先,RMQ是在一段数列中寻找最小或最大的值,这里用RMQ来寻找深度序列中的最小值。先用dfs深度遍历跑一遍,把深度序列及每个元素第一次出原创 2015-12-04 14:45:12 · 719 阅读 · 0 评论 -
G - Closest Common Ancestors
G - Closest Common AncestorsTime Limit:2000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionWrite a program that takes as input a rooted tree原创 2016-02-26 14:52:58 · 467 阅读 · 0 评论 -
F - Nearest Common Ancestors
F - Nearest Common AncestorsTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionA rooted tree is a well-known data structure in co原创 2016-02-26 20:58:51 · 587 阅读 · 0 评论