### raman92's blog

By raman92, 6 years ago, ,

I am solving this question: http://www.codechef.com/problems/FLIPCOIN/ but getting wrong answer.

My solution is: http://pastebin.com/bDbfwtjM

my idea:

each time update is called if the flag==0 for the current node and current node needs to be flipped flag[left child]=(flag[left child]+1)%2 , flag[right child]=(flag[right child]+1)%2 is done and the value of the current node is changed.

if the flag==1 current flag is set to 0. current is not flipped. flag[left child]=(flag[left child]+1)%2 , flag[right child]=(flag[right child]+1)%2