
并查集
小·幸·运
你的所有努力最后都会回赠予你。
展开
-
并查集python版本模版
在做leetcode399题除法求值时用到了并查集,在这里把模版贴出来记录一下。 class UnionFind: def __init__(self): self.father = {} ##记录每个节点的父节点 def find(self, x): root = x while self.father[root] != None: #寻找根节点 root = self.father[root] .原创 2021-01-06 18:19:05 · 184 阅读 · 0 评论 -
PAT甲级A1114 Family Property (25 分)
This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f...原创 2019-03-01 15:09:59 · 249 阅读 · 0 评论 -
PAT甲级A1107 Social Clusters (30 分)
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set of people who have some of thei...原创 2019-02-26 21:26:05 · 204 阅读 · 0 评论 -
PAT甲级A1118 Birds in Forest (25 分)
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maxi...原创 2019-03-01 19:28:14 · 200 阅读 · 0 评论