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

Автор NeverSayNever, история, 6 лет назад, По-английски

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 ?

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

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

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

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

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.