I’ve solved this question using union-find algorithm. But i only get AC when I check j in range [1,100] (maximum range of m). To clarify I’m referring to the loop in line 62. When I only check j in range [1,m], I get WA. Why is this?
Here is my AC code: CodeChef: Practical coding for everyone
And here is the code that gets WA: CodeChef: Practical coding for everyone
The only difference between the two programs is the range of j in line 62.
I would really really really appreciate it if somebody could answer this! Thanks!!!