随笔分类 -  LCA

最近公共祖先(LCA)
SPOJ 10628. Count on a tree (树上第k大,LCA+主席树)
摘要:10628. Count on a treeProblem code: COTYou are given a tree withNnodes.The tree nodes are numbered from1toN.Each node has an integer weight.We will ask you to perform the following operation:u v k: ask for the kth minimum weight on the path from nodeuto nodevInputIn the first line there are two inte 阅读全文

posted @ 2013-09-07 07:42 kuangbin 阅读(2075) 评论(0) 推荐(0) 编辑

POJ 1330 Nearest Common Ancestors (LCA,倍增算法,在线算法)
摘要:1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2013-9-5 9:45:17 4 File Name :F:\2013ACM练习\专题学习\LCA\POJ1330_3.cpp 5 ************************************************ */ 6 7 #include 8 #include 9 #include 10 #include 11 #include 12 #i... 阅读全文

posted @ 2013-09-05 10:22 kuangbin 阅读(2329) 评论(0) 推荐(0) 编辑

POJ 1470 Closest Common Ancestors (LCA,离线Tarjan算法)
摘要:Closest Common AncestorsTime Limit:2000MSMemory Limit:10000KTotal Submissions:13372Accepted:4340DescriptionWrite a program that takes as input a rooted tree and a list of pairs of vertices. For each pair (u,v) the program determines the closest common ancestor of u and v in the tree. The closest com 阅读全文

posted @ 2013-09-05 09:34 kuangbin 阅读(1676) 评论(0) 推荐(0) 编辑

POJ 1470 Closest Common Ancestors (LCA, dfs+ST在线算法)
摘要:Closest Common AncestorsTime Limit:2000MSMemory Limit:10000KTotal Submissions:13370Accepted:4338DescriptionWrite a program that takes as input a rooted tree and a list of pairs of vertices. For each pair (u,v) the program determines the closest common ancestor of u and v in the tree. The closest com 阅读全文

posted @ 2013-09-05 09:03 kuangbin 阅读(628) 评论(0) 推荐(0) 编辑

POJ 1330 Nearest Common Ancestors (LCA,dfs+ST在线算法)
摘要:Nearest Common AncestorsTime Limit:1000MSMemory Limit:10000KTotal Submissions:14902Accepted:7963DescriptionA 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 integer from {1, 2,...,16}. Node 8 is the 阅读全文

posted @ 2013-09-05 08:42 kuangbin 阅读(1149) 评论(0) 推荐(0) 编辑

HDU 4547 CD操作(LCA)
摘要:CD操作Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 78Accepted Submission(s): 14Problem Description 在Windows下我们可以通过cmd运行DOS的部分功能,其中CD是一条很有意思的命令,通过CD操作,我们可以改变当前目录。 这里我们简化一下问题,假设只有一个根目录,CD操作也只有两种方式: 1. CD 当前目录名\...\目标目录名 (中间可以包含若干目录,保证目标目录通过绝对路... 阅读全文

posted @ 2013-05-17 21:37 kuangbin 阅读(1126) 评论(0) 推荐(0) 编辑

POJ 1470 Closest Common Ancestors (LCA入门题)
摘要:Closest Common AncestorsTime Limit: 2000MSMemory Limit: 10000KTotal Submissions: 11659Accepted: 3848DescriptionWrite a program that takes as input a rooted tree and a list of pairs of vertices. For each pair (u,v) the program determines the closest common ancestor of u and v in the tree. The closest 阅读全文

posted @ 2012-09-21 19:08 kuangbin 阅读(609) 评论(0) 推荐(0) 编辑

POJ 1330 Nearest Common Ancestors (LCA入门题)
摘要:Nearest Common AncestorsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 12478Accepted: 6652DescriptionA 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 integer from {1, 2,...,16}. Node 8 . 阅读全文

posted @ 2012-09-21 19:07 kuangbin 阅读(1388) 评论(0) 推荐(0) 编辑

导航

JAVASCRIPT: