【题解】P5210 [ZJOI2017] 线段树
https://www.luogu.com.cn/problem/P5210
定位线段树节点:\(l-1\) 祖先链上所有右儿子,\(r+1\) 祖先链上所有左儿子。\(\operatorname{LCA}(l-1,r+1)\) 祖先链上所有的儿子不算。
那么就很好做了吧,对于给定的 \(u\),分讨一下 \(\mathrm{LCA}(u,v)\),就能求了。
时间复杂度 \(O(n\log n)\)。
https://www.luogu.com.cn/problem/P5210
定位线段树节点:\(l-1\) 祖先链上所有右儿子,\(r+1\) 祖先链上所有左儿子。\(\operatorname{LCA}(l-1,r+1)\) 祖先链上所有的儿子不算。
那么就很好做了吧,对于给定的 \(u\),分讨一下 \(\mathrm{LCA}(u,v)\),就能求了。
时间复杂度 \(O(n\log n)\)。