Need a little help in FLIPCOIN(segment tree) problem

My approach is :- Initially all are tails(represented by 0) and heads is represented by 1.So if we have initially n coins each having tails up.If we have to update l to r range so number of heads will become = ((r-l)+1)-current total heads we have.
But by code is giving wrong answer though for sample test it is passing.
problem link
Sol-CodeChef: Practical coding for everyone
Thanks in Advance.