摘要:
#!/usr/bin/env python3.3# -*- coding:utf-8 -*-# Copyright 2013'''并查集1)合并两个不相交集合2)判断两个元素是否属于同一个集合'''class UnionFindSet: def __init__(self): self.root = {} self.rank = {} def make_set(self, x): self.root[x] = x self.rank[x] = 0 def find(self, x): root = ... 阅读全文