I'm trying to write segment tree with operation of (=) - When in comes to insert([a,b],c) all of element from interval [a,b] will be equal to c.
As for query(a,b) it will be sum of elements from interval [a,b].
Look at example:
insert(1, 5, 11)
Elements from interval [1,5] are equal to 11.
query(0,100) return value 5*11 = 55.
And now:
insert(3,6, 2)
Let's look at query(0,100) - it is 2*11 + 4*2 = 22+8=30.
As we see, two elements have new value 11 -> 2.
I can write segment tree with insert (sum - not replace). and query(sum, like in case described by me).
Any suggestions?