树的重心也叫树的质心。对于一棵树n个节点的无根树,找到一个点,使得把树变成以该点为根的有根树时,最大子树的结点数最小。换句话说,删除这个点后最大连通块(一定是树)的结点数最小。
Kruskal是一种用于建立最小生成树(MST)的算法,同理的还有Prim算法。与Kruskal算法相关的还有并查集,也就是说Kruskal的实现需要并查集(可参考蒟蒻的OI笔记)。
Farmer John's N cows (1 <= N <= 50,000) are grazing along a one-dimensional fence. Cow i is standing at location x(i) and has height h(i) (1 <= x(i),h(i) <= 1,000,000,000).