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 <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
int construct(vector<vector<int>> p) {
vector<vector<int>> b(p.size(), vector<int>(p.size(), 0));
int n = (int) p.size();
vector<int> par(n);
for (int i = 0; i < n; i++) par[i] = i;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (p[i][j]) par[j] = i;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (par[i] == par[j] && p[i][j] == 0) return 0;
if (par[i] != par[j] && p[i][j] == 1) return 0;
}
}
for (int i = 0; i < n; i++) {
if (par[i] != i) {
b[i][par[i]] = 1;
b[par[i]][i] = 1;
}
}
build(b);
return 1;
}
# | 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... |