Rollback Mo's Algorithm

Applicable Scenarios Offline problems where expanding intervals is easier to maintain than shrinking. Variants exist for "remove-only" Mo's algorithm. Example Problem: P5906 [Template] Rollback Mo's Algorithm Given an array, process multiple queries to find the maximum distance between two equal elements within a given interval. Con ...

Posted on Mon, 14 Sep 2026 16:14:11 +0000 by Azala

Minimizing Interval Length Difference for Common Intersection Using Segment Trees

Given $n$ closed intervals on a number line, the objective is to select exactly $m$ intervals such that they share at least one common coordinate point. The cost of a selection is defined as the difference between the maximum length and the minimum length among the chosen intervals. The length of an interval $[l, r]$ is calculated as $r - l$. T ...

Posted on Fri, 08 May 2026 22:58:06 +0000 by Jak-S