Yath's blog

By Yath, history, 2 years ago, In English

My code is giving runtime error for all the cases that have n=1e5 and m = 2e5 input — Test cases 6 , 7 , 8 and 9 on the CSES website. Here is the submission: https://onlinegdb.com/ciDQleE8W

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
2 years ago, # |
  Vote: I like it +1 Vote: I do not like it

For this input

Input
Graph

your code finds the circle (2,4,3) twice and ends up setting v = 3 and parent[3] = 1. Which is not the parent you want. Now the while loop will never stop, which causes ans to get larger and larger until it is too large and you get runtime error.