FLIPCON with segment tree lazy propogation

I am trying to solve this qstn FLIPCOIN.I Problem - CodeChef thought lazy propagation of segment tree will work but I am getting wrong answer please check my approach and code

Approach

1)Initialize the array having all elements as tail arr[i]=1

2)Built the segment tree which count number of tail in a range

3)flip coin between range (a,b) ==>will update tree[si]=(b1-a1+1-tree[si]) where range[a1-b1] lies between (a,b)

{(query(a,b)=gives number of tail)}

4)find number of head therefore head=b-a+1-query(a,b);

Code:esQtij - Online C++ Compiler & Debugging Tool - Ideone.com

This is what I’m getting when I execute your code
Input:
5 3
0 1 4
0 1 4
1 1 3
Output
1