This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
vector<int> par, rnk;
int root(int a) {
if (a == par[a])
return a;
return par[a] = root(par[a]);
}
void merge(int i, int j) {
int a = root(i), b = root(j);
if (a == b)
return;
if (rnk[a] < rnk[b])
par[a] = b;
else if (rnk[a] > rnk[b])
par[b] = a;
else {
par[b] = a;
rnk[b]++;
}
}
void initialize(int N) {
par = vector<int>(N);
for (int i = 0; i < N; i++)
par[i] = i;
rnk.assign(N, 0);
}
int hasEdge(int u, int v) {
if (u > v) return 1;
else return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |