[파이썬] 4803 트리
import sys input = sys.stdin.readline def find_parent(x): if parent[x] != x: return find_parent(parent[x]) return x def union_parent(a, b): a = find_parent(a) b = find_parent(b) if a != b: parent[max(a, b)] = min(a, b) edge_count[min(a, b)] = edge_count.get(min(a, b), 0) + 1 i = 1 while True: n, m = map(int, input().split()) if not n + m: break parent = list(range(n)) node_count, edge_count = {}..