随笔分类 -  数据结构--树的直径

摘要:传送门 题意:给定一颗n个结点的树,树上有m个结点有队伍,求存不存在一个点s,到所有m个队伍所在结点的距离相等,如果存在输出可能一个的s。 分析:假设存在s,那么可以改变树的顺序,使得s是所有队伍结点的祖先,此时s的所有祖先都是满足的s,令所有满足条件的s中里队伍结点最近的s为ms。dfs可以求得队 阅读全文
posted @ 2019-11-07 21:08 千摆渡Qbd 阅读(1241) 评论(0) 推荐(0)
摘要:Computer HDU - 2196 A school bought the first computer some time ago(so this computer's id is 1). During the recent years the school bought N-1 new co 阅读全文
posted @ 2019-01-23 18:49 千摆渡Qbd 阅读(220) 评论(0) 推荐(0)
摘要:Terrorist’s destroy HDU - 4679 There is a city which is built like a tree.A terrorist wants to destroy the city's roads. But now he is alone, he can o 阅读全文
posted @ 2019-01-23 15:31 千摆渡Qbd 阅读(297) 评论(0) 推荐(0)
摘要:Roads in the North POJ - 2631 Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads 阅读全文
posted @ 2019-01-22 18:41 千摆渡Qbd 阅读(118) 评论(0) 推荐(0)
摘要:Labyrinth POJ - 1383 The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, ea 阅读全文
posted @ 2019-01-22 18:39 千摆渡Qbd 阅读(160) 评论(0) 推荐(0)