https://www.acmicpc.net/problem/14621최소 스패닝 트리 문제입니다.Union 을 진행하기 전에 엣지의 양끝에 있는 노드가 다른 성별을 이루고 있는지만 추가적으로 확인하면 풀 수 있습니다.import sysinput = sys.stdin.readline## Union-Find# Uniondef Union(group_list, node1, node2): # 그룹 g1 = Find(group_list, node1) g2 = Find(group_list, node2) # 같은 그룹이면 if g1 == g2: # 변합하지 않음 return False, group_list # 다른 그룹이면 작은 그룹으로 병합 if g1 > ..