- 2024-03-02CF1856E1 PermuTree (easy version) 题解
假定当前在节点\(u\),它拥有两棵子树\(v,w\),此时\(u\)是\(\operatorname{lca}(v,w)\)。我们一定可以构造出一个排列\(a\),使得所有满足\(i\inv\)的节点\(i\)和满足\(j\inw\)的节点\(j\),有\(a_i<a_u<a_j\)。因此此时点\(u\)对于答案的贡献即为\(size_v\times
- 2023-11-07cf1856E2. PermuTree (hard version)(bitset+二进制优化背包+开不同大小bitset)
https://codeforces.com/contest/1856/problem/E2结论是显然的,关键是有一些科技在里面bitset+二进制优化具体分析可以参考https://codeforces.com/blog/entry/98663简而言之就是可以通过\(O(\frac{C\sqrtC}{w})\)的复杂度判断是否能够获得某种体积开不同大小bitsettemplate
- 2023-08-07E1. PermuTree (easy version)
E1.PermuTree(easyversion)Thisistheeasyversionoftheproblem.Thedifferencesbetweenthetwoversionsaretheconstrainton$n$andthetimelimit.Youcanmakehacksonlyifbothversionsoftheproblemaresolved.Youaregivenatreewith$n$
- 2023-08-06CodeForces 1856E1 PermuTree (easy version)
洛谷传送门CF传送门考虑局部贪心,假设我们现在在\(u\),我们希望\(u\)不同子树中的\((v,w),a_v<a_u<a_w\)的对数尽量多。我们实际上只关心子树内\(a_u\)的相对大小关系,不关心它们具体是什么。如果\(u\)只有两个儿子\(v,w\),我们可以让\(v\)子树内的\(a\)全部
- 2023-08-06CodeForces 1856E2 PermuTree (hard version)
洛谷传送门CF传送门考虑局部贪心,假设我们现在在\(u\),我们希望\(u\)不同子树中的\((v,w),a_v<a_u<a_w\)的对数尽量多。我们实际上只关心子树内\(a_u\)的相对大小关系,不关心它们具体是什么。如果\(u\)只有两个儿子\(v,w\),我们可以让\(v\)子树内的\(a\)全部