No Abstract.

# Des.

There are several segments on a line, with $l$ and $r$ as end points.

Every time choose the shortest line (might be with a length of 0), and erase it. But once a part of line is erased, it won’t be calculated in other segments’ lengths.

It is guaranteed that there’s won’t be any segment whole in another.

# Sol.

Seems that we can use a Segment Tree to maintain the shortest line, but as in description, the end points of segments are dynamic.

Notice that after a segment is erased, some other segments’ $l$ points or $r$ points will be the same, and always keep the same from then on. So we can have two UFS for $l$ and $r$ separately, and merge the sets in an operation. All elements in a set will decrease the same length after an operation, that’s what we can deal with the help of Segment Tree.