# Something is wrong in the judge system

• Something is wrong in the judge system.
Maybe there is some bug in my code, but definitely the report from the judge is wrong.

``````class Solution {
public:
vector<int> father;
vector<int> rank;

int getfather(int x) {
if (father[x] == 0) return 0;
if (father[x] == x) return x;
father[x] = getfather(father[x]);
return father[x];
}

int Union(int x, int y) {
int rx = getfather(x);
int ry = getfather(y);
if (rx == ry) return rx;
if (rank[x] < rank[y]) {
father[rx] = ry;
return ry;
} else {

father[ry] = rx;
if (rank[x] == rank[y]) {
rank[x] += 1;
}
return rx;
}
}

vector<int> findRedundantConnection(vector<vector<int>>& edges) {

father.resize(2001);
rank.resize(2001);
for (int i = 0; i <=2000; i++) {father[i] = rank[i] = 0;}
for (auto const& e :edges) {
int e0 = e[0];
int e1 = e[1];
int f0 = getfather(e0);
int f1 = getfather(e1);

if (f0 == 0) {

father[e0] = e0;
if (f1 == 0) {
father[e1] = e0;
rank[e0] = 1;
} else {
printf("add %d union with %d\n", e0, e1);
Union(e0, e1);
}
} else {
if (f1 == 0) {
father[e1] = e1;
printf("add %d union with %d\n", e1, e0);
Union(e0, e1);
} else {
if (f0 == f1) {
for (int i = 1; i < 10; i++) printf("%d,", father[i]);
cout << "\n";
return e;
} else {
printf("union %d %d\n", e0, e1);
Union(e0, e1);
}
}
}
}
return vector<int>(0);
}
};
``````

• I met the same problem!

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.