How to properly implement disjoint set data structure for finding spanning forests in Python?
问题 Recently, I was trying to implement the solutions of google kickstater's 2019 programming questions and tried to implement Round E's Cherries Mesh by following the analysis explanation. Here is the link to the question and the analysis. https://codingcompetitions.withgoogle.com/kickstart/round/0000000000050edb/0000000000170721 Here is the code I implemented: t = int(input()) for k in range(1,t+1): n, q = map(int,input().split()) se = list() for _ in range(q): a,b = map(int,input().split()) se