Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Ordering Issue Causing TLE

Revision en1, by muichirotokito, 2024-07-23 07:09:10

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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English muichirotokito 2024-07-23 07:09:10 648 Initial revision (published)