Given n segments, each segment are described by three numbers l_i, r_i and v_i. We want to make some queries:
- Change v_i for some segment i for some number x, so from now v_i = x.
- How many distinct values v_i are written on segments, such that l_i \leq x \leq r_i for some x. We know that for some segment i we have l_i = x.
We have all queries given so maybe we can answer offline?
I suspect segment trees or persistent segment trees may be useful, maybe sqrt decomposition.