Codeforces 686 D. Kay and Snowflake 要求$O(n)$求出以每个节点为根的重心. 考虑对于一个根节点$u$,其重心一定在[各个子树的重心到$u$]这条链上.这样就能够$O(n)$推出来了.证明起来难证易忘.不如记住树的重心的几条奇妙性质: 1. 以重心为根,各子树大小都不超过树的一半. 2. 已知一子树$v$的重心为$x$,则$v$父节点$u$的重心一定在$(x,u)$这条链上. ... 下次用到了再说 Codeforces 842 C. Ilya And Th…
Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4478 Accepted: 1292 Description Yixght is a manager of the company called SzqNetwork(SN). Now she's very worried because she has just received a bad news which denotes that DxtNet…