方法:并查集+哈希
暴力枚举所有 properties[i] 和 properties[j],如果交集为k直接用并查集合并 i 和 j,并continue。
优化1:用哈希枚举。为防止不同整数重复加,哈希properties[i]在hash0,在查properties[j]时,用copy一下hash0为hash,当加过就hash【】=0
优化2:先find(i),find(j),如果连通就continue
暴力枚举所有 properties[i] 和 properties[j],如果交集为k直接用并查集合并 i 和 j,并continue。
优化1:用哈希枚举。为防止不同整数重复加,哈希properties[i]在hash0,在查properties[j]时,用copy一下hash0为hash,当加过就hash【】=0
优化2:先find(i),find(j),如果连通就continue