pandeyadarsh's blog

By pandeyadarsh, history, 9 years ago, In English

I submitted code for Div2 408 Problem C. And it showed runtime error for the test case 2 while on my pc it is giving fine result although my algo is wrong but I still don't get why this one occured I check the same code on hackerrank and it gave proper result there too. Can anyone tell what's happened? this is my code

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

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

I can tell you that int pretest 2, when your program is running at line 75, cal(root) (which root=4) called cal(2), then called cal(1), then at line 36, neighbor.size() is 1 but you tried to read neighbor[j] which j = 1, and it caused RE.