版本比较
The Doubling Game 2
正文
增加 4 行删除 4 行
17 行未改动1819202122222324242526262728293062 行未改动939495969797989910017 行未改动
Firstly we have to notice, that if $\max(v)$ denotes the highest number of tokens that can be gathered in vertex $v$, then the sum of values $\max()$ for all vertices is $O(n\log n)$ (the proof is not that hard, focus on the tree compressed to vertices with $\max() ≥ x$ and on vertices with degree $≤$ 2 in it).
我不会证。
然后乘上转移均摊的一个 $\log$ 总复杂度 $O(n\log^2n)$。
```cpp#include<iostream>#include<cstring>#include<algorithm>62 行未改动 T[u].push_back(v),T[v].push_back(u); } dfs(1,0); cout<<ans[1];
return 0;}```