2014年7月27日

How far away ?

摘要: hdu2586:http://acm.hdu.edu.cn/showproblem.php?pid=2586题意:给你一棵树,然后询问任意两点之间的距离。题解1:直接用spfa,求最短路,因为只有40000-1条边,200个查询,所以应该可以过。 1 #include 2 #include 3 #i... 阅读全文

posted @ 2014-07-27 15:21 天依蓝 阅读(190) 评论(0) 推荐(0) 编辑

Nearest Common Ancestors

摘要: poj1330:http://poj.org/problem?id=1330题意:求一棵树上的两点的最近的公共祖先。题解:第一次接触LCA,第一道模板题。 1 #include 2 #include 3 #include 4 #include 5 using namespace s... 阅读全文

posted @ 2014-07-27 14:13 天依蓝 阅读(169) 评论(0) 推荐(0) 编辑

Cutting Sticks

摘要: uva10003:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=944题意:给你一个木棍,然后让你切n刀,每次切都会有一个费用。例如,假如说一开始木棍长是1... 阅读全文

posted @ 2014-07-27 09:18 天依蓝 阅读(178) 评论(0) 推荐(0) 编辑

导航