WA in FLIPCOINS

problem :: FLIPCOIN Problem - CodeChef
SOLUTION :: CodeChef: Practical coding for everyone

I am again and again getting wa…
initially i used segmented trees with no lazy optimization and was getting tle
but now after lazy optimization i am getting wa again again
I am not able to figure out the test case in which my code fails
Please help me with the rectifation of this code…

A couple of things are wrong in your code:
1)The updating of the flags of the children should be done this way flag[2i]=(!flag[2i)) .I hope you understand why we have to do so.If not i can explain :slight_smile:
2)You were updating the wrong children … Instead of updating the 2ith and 2i+1 th node you were wrongly updating the 2i+1th and 2i+2 th node

Do these two changes and you will get AC :slight_smile:
Have a look at this code (Ur code with above mentioned changes which got AC :slight_smile: )
http://www.codechef.com/viewsolution/4169771

1 Like

thanku for ur reply
I do undersatnd my mistake…
I rectified my code and sucessfully got ac
It was my first segmented tree problem…