SPOJ(Horrible Queries) :- https://www.spoj.com/problems/HORRIBLE/
CODE:- https://ide.codingblocks.com/s/120107
I am able to understand the question build and query a segment tree, but it is giving WA
Edit: Got AC in 6th Attempt, cleared the lazy and segment tree arrays till 4*n values instead of n-1 (This was mentioned in one of the comments under the question)
Still I am not able to understand why 2 * nextpowerof2(n) - 1 is giving wrong answer?