NeverSayNever's blog

By NeverSayNever, history, 6 years ago, In English

Hi Folks,

I wrote the this solution for this Tree Constructing but i kept getting runtime error during the contest. Though i managed to get my solution accepted by changing few things but still did not understand why i was getting runtime error. Can anybody help here ?

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

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why don't you explain what you changed to solve runtime error.

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Below your submission you can see in which case your solution fails and a hint of the RTE. In this case the message is:

Diagnostics

Diagnostics detected issues [cpp.clang++-diagnose]: p71.cpp:120:58: runtime error: index -1094795586 out of bounds for type 'int [400010]' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior p71.cpp:120:58 in

Check this part: index -1094795586 out of bounds for type 'int [400010]'

You're trying to acces in to a negative position.

By your code, i can say is this one: int deg[4 * 100000 + 10];

I hope it will help you.