beowulf's blog

By beowulf, history, 7 years ago, In English

I am stumped on 29958547. What is the error in the code which hasn't been discovered till test case 15. If the entire approach is wrong, please don't reveal the the correct approach, just say that the approach is wrong. However if a silly error has been committed please point it out.

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +11 Vote: I do not like it

It seems to me that you are assuming x<y in edges.

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

    Could you elaborate a little please?

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

      You are iterating over x=2..n and assuming that parent(x) is already processed, which means that you are assuming parent(x)<x.