Problem 715 · Hard

Range Module

Keep disjoint half-open intervals; adding merges neighbours, removing splits them, and queries check one interval.

Open the interactive visualisation