When I do an exercise I have a problem that let Ai <= 60 and n <= 1e5 and q <= 1e5, Count number of distinct elements in l to r. With type 1 query update change all elements from l to r to v. Type 2 query answer the number of distinct elements from l to r.
Example:
5 5
1 1 1 1 1
1 2 4 2
1 5 5 3
2 1 5 // is 3.
2 1 4 // is 2.
2 2 4 // is 1.
I know how if we update an element we can do this with the segment tree. But i don't know updating the range. Is this possible? if yes please explain to me. thanks for help!