update in BIT

Правка en1, от t3rminated, 2016-12-20 10:12:29

If i have an update condition like if i want to assign all elements in range (l,r) with a value x(x!=0) and i have many updates like this , for example —

l r x 1 4 2 3 4 3 7 8 9

now if i want to query for an index y , then can i do this using BIT? I have come up with this solution but it isn't working —

update(l, x) update(r+1, 0) #0 means index still unassigned.

now if i query for like index 4(read(4) — read(4-1)) i am not getting the correct answer. Is my approach correct ?

Теги bit

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский t3rminated 2016-12-20 10:14:44 31
en1 Английский t3rminated 2016-12-20 10:12:29 538 Initial revision (published)