i used the following lazy propogation to update my tree...like i wanted to get sum of [i,j]
my input was n=8;all elements set to zero.'0'.
then i gave my array number 26 to update array from i=1 to i=3;[1,3]
but i am getting tree[1]=52 instead of 78....
could any one say where i am getting wrong.....
thanks in advance
Why in function bt you do this :
instead this:
?
yes,,,,i updated my solution....even though my tree[1] is 52.could u say where it is wrong.
Well, your ut function is wrong. I can send u my solution of this problem, but it will be in java.
could you pls send code....and tell he logic in description...pls,
http://pastebin.com/vFwnvq6X
My solution in c++. I coded this long time ago.
could i get solution through lazy propogation....because i got TLE with
the following problem
http://www.spoj.com/problems/HORRIBLE/
Yes, if you want to update array from p to q with v, call upd(1,1,n,p,q,v), and if you want to get sum from p to q , call sum(1, 1, n, p, q)
dont we get tle for the problem i asked...?
It's O(log(n)) for one query, build function is o(n log(n)), and it should be ok.
i got TLE
Try fast IO.
TLE
Can you give me your code that got tle?
My accepted solution. Hope it helps.