union_find(并查集)

来源:互联网 发布:vb.net中单选按钮 编辑:程序博客网 时间:2024/06/09 22:59
int find(int x) {    if (x != fa[x])        fa[x] = find(fa[x]);    return fa[x];}void union (int x, int y) {    int a = fin(x), b = find(y);    if (a != b)         fa[b] = a;}

优化:http://www.360doc.com/content/15/0904/22/9482_496925571.shtml

原创粉丝点击