CSP-S T3 的线性做法 kyhdp · 2025-11-04 08:41:16 · 个人记录 做法 建议先阅读 lzyqwq 的题解。 我们可以注意到这个做法的复杂度瓶颈在于最后的多层分块。 考虑使用多叉线段树解决,设其为 B 叉。 那么时间复杂度为 \Omicron(L+nB\log_BL+L\log_BL)。 考虑取 B=\frac{L}{n},那么复杂度为 \Omicron(L+\frac{L\log L}{\log L-\log n})=\Omicron(\frac{2L\log L-L\log n}{\log L-\log n})=\Omicron(\frac{L\log L-L\log n}{\log L-\log n })=\Omicron(L)。 这样我们就做到线性了。有个小于 5 的常数。 记得特判 L<2n。 代码 稍后补。