Hi Everyone, I am currently stuck at this problem : https://codeforces.com/contest/1253/problem/D
AC code : https://codeforces.com/contest/1253/submission/271988149
TLE code : https://codeforces.com/contest/1253/submission/272003978
I am trying to solve it by using DSU. My solution is getting accepted when I am sorting the edges in descending order. The only difference is that I have removed the sort in the code which is giving TLE.
My understanding is that ordering of edges should not matter for this problem and I also don't think the issue is DSU operations because I am using the union by rank.