이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
const int mxN = 1007;
int dsu[mxN];
int find(int x) {
return dsu[x] < 0 ? x : dsu[x] = find(dsu[x]);
}
bool unite(int x, int y) {
x = find(x), y = find(y);
if (x == y) {
return false;
}
if (dsu[x] > dsu[y]) {
swap(x, y);
}
dsu[x] += dsu[y];
dsu[y] = x;
return true;
}
int construct(vector<vector<int>> p) {
int n = p.size();
memset(dsu, -1, sizeof(dsu));
vector<vector<int>> ans(n, vector<int>(n));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (p[i][j]) {
int x = find(i), y = find(j);
if (x != y) {
ans[x][y] = ans[y][x] = 1;
unite(x, y);
}
}
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (!p[i][j] && find(i) == find(j)) {
return 0;
}
}
}
build(ans);
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... |