并查集

def find(x):
    if (p[x] != x):
        p[x] = find(p[x])
    return p[x]

上面是y总的模板,实现了路径压缩。

使用 Hugo 构建
主题 Stack 由 Jimmy 设计