raman92's blog

By raman92, 12 years ago, In English

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

Please help me where the solution is wrong.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it