# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
365014 | Farrius | Connecting Supertrees (IOI20_supertrees) | C++14 | 274 ms | 24172 KiB |
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 "supertrees.h"
#include <vector>
using namespace std;
struct DSU {
vector<int> e;
void init (int n) {e = vector<int>(n, -1);}
int get (int x) {return e[x] < 0 ? x : e[x] = get(e[x]);}
bool sameSet (int x, int y) {return get(x) == get(y);}
bool unite (int x, int y) {
x = get(x), y = get(y);
if (x == y) return false;
if (e[x] > e[y]) swap(x, y);
e[x] += e[y];
e[y] = x;
return true;
}
};
int construct(vector<vector<int>> p) {
//take input
int n = p.size();
vector<vector<int>> sol(n, vector<int>(n));
DSU dsu;
dsu.init(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (p[i][j] >= 1) {
dsu.unite(i, j);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |