Union found

Posted The Tech Road

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Union found相关的知识,希望对你有一定的参考价值。

 

class UnionFound {
public:
    vector<int> v;
    int cnt;
    UnionFound(int n) {
        v = vector<int>(n);
        for (int i = 0; i < n; i++)
            v[i] = i;
        cnt = n;
    }
    int findParent(int i) {
        if (v[i] == i)  return i;
        v[i] = findParent(v[i]);
        return v[i];
    }
    void Union(int p, int c) {
        int pp = findParent(p);
        int cp = findParent(c);
        if (pp != cp) {
            v[cp] = pp;
            cnt--;
        }
    }
};

 

以上是关于Union found的主要内容,如果未能解决你的问题,请参考以下文章

报错“Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“(代码片段

报错:✘ http://eslint.org/docs/rules/indent Expected indentation of 0 s paces but found 2(代码片段

报错:✘ http://eslint.org/docs/rules/indent Expected indentation of 0 s paces but found 2(代码片段

[react] Module not found: Can't resolve 'schedule' in 'C:Usersadcaldvmtn7myapp (代码片段

解决go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘(代码片段

IllegalArgumentException: No view found for id for fragment --- ViewPager in ViewPager