SbrTa's blog

By SbrTa, history, 8 years ago, In English

Getting WA on This problem. My Solution . Can anyone plz suggest me anything to improve it.

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

»
8 years ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

u made a wrong assumption, try this tc:

1

1

10

0

4

F 0 9

E 0 9

I 0 9

S 0 4

answer for the query should be 5

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Many many thanks for this tc. Now i have the bug. i made wrong when flipping. for example when flipping the left child — i used : if(Left.p==0) Left.p=1; if(Left.p==1) Left.p=0; if(Left.p==2) Left.p=-1; if(Left.p==-1) Left.p=2;

    But it should be: if(Left.p==0) Left.p=1; else if(Left.p==1) Left.p=0; else if(Left.p==2) Left.p=-1; else if(Left.p==-1) Left.p=2;

    & now it's Accepted.. Thanks again.. :)