Question about counting the number of distinct elements in l to r and update range?

Revision en1, by wonderful_trip, 2021-07-02 16:26:23

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!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English wonderful_trip 2021-07-02 16:26:23 626 Initial revision (published)