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









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