Блог пользователя raman92

Автор raman92, 12 лет назад, По-английски

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.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
12 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

It's good idea to make bruteforce solution then make random test then compare between the output of segment tree and the output of bruteforce solution and and the bug

»
12 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

flag[2*nd+1] += (flag[2*nd+1]+1)%2; flag[2*nd+2] += (flag[2*nd+2]+1)%2;

not =