题目链接: C3. Brain Network (hard) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Breaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born …
C3. Brain Network (hard)   Breaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born with a single brain, and only later it evolves into a complicated brain structure. In fact, whenever a zombie cons…
题目链接: C2. Brain Network (medium) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Further research on zombie thought processes yielded interesting results. As we know from the previous prob…
题目链接: C1. Brain Network (easy) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One particularly well-known fact about zombies is that they move and think terribly slowly. While we still do…
题目描述 Brain Network (hard) 这个问题就是给出一个不断加边的树,保证每一次加边之后都只有一个连通块(每一次连的点都是之前出现过的),问每一次加边之后树的直径. 算法 每一次增加一条边之后,树的直径长度要么不变,要么会增加1,并且如果树的直径长度增加1了,新的直径的端点其中一个必然是新增的点,而另一个是原来直径的某个端点.关于为什么可以这样做,在Quora上有个回答解释地不错,可以参考. 实现 所以这个问题其实就是要计算树上任意两个点的距离,LCA可以很轻松地处理. 可以一次…
H - Brain Network (medium) Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u CodeForces 690C2 Description Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the…
G - Brain Network (easy) Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u CodeForces 690C1 Description One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know…
Brain Network (medium) Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. I…
Brain Network (easy) One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out tha…
poj 3417 Network(tarjan lca) 先给出一棵无根树,然后下面再给出m条边,把这m条边连上,然后每次你能毁掉两条边,规定一条是树边,一条是新边,问有多少种方案能使树断裂. 我们设添加了一条新边后,树形成了一个环,表示为x->y->lca(x,y),我们将其中的边都覆盖一次.添加了多条新边后,可知树上有些边是会被多次覆盖的,画图很容易发现,但一个树边被覆盖了2次或以上,它就是一条牢固的边,就是说毁掉它再毁掉任何一条新边都好,树都不会断裂.所以我们只要统计被覆盖过零次或一次的…