06 2011 档案
LCA 练习总结
摘要:LCA 资料: http://www.cnblogs.com/zgmf_x20a/archive/2008/10/15/1311313.html虽然网上这方面资料很多了, 不过自己练习后还是写下。。。POJ1330NearestCommonAncestors输入N-1条边,建一个树,然后是一个LCA查询,只有一次,朴素做比较快。树是唯一的。POJ1470ClosestCommonAncestors和上一题非常类似,不过点变少了,查询次数变多了,因为n<=900朴素就可以了。POJ1986DistanceQueries查询从u-v的距离。根据输入建一个树,以任意点位根都可以,距离是不变的。 阅读全文
posted @ 2011-06-13 16:46 cegr 阅读(1224) 评论(2) 推荐(2)
UVALIVE 5061 - Lightning Energy Report(LCA)
摘要:The city of Thunder has many houses and they are powered by lightning. Two houses may be interconnected by a wire. The wires connect the houses such that there is exactly one path from one house to any other house in the city. Each house has a large battery that can store infinite electrical energy. 阅读全文
posted @ 2011-06-07 11:12 cegr 阅读(359) 评论(0) 推荐(0)