# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769083 | t6twotwo | Connecting Supertrees (IOI20_supertrees) | C++17 | 178 ms | 24056 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 <bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> a) {
int N = a.size();
vector<vector<int>> s(N);
vector<bool> vis(N);
for (int i = 0; i < N; i++) {
if (vis[i]) {
continue;
}
vis[i] = 1;
queue<int> q;
q.push(i);
while (!q.empty()) {
int x = q.front();
q.pop();
s[i].push_back(x);
for (int y = 0; y < N; y++) {
if (!vis[y] && a[x][y]) {
vis[y] = 1;
q.push(y);
}
}
}
}
vector ans(N, vector<int>(N));
for (auto &v : s) {
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
if (!a[v[i]][v[j]]) {
return 0;
}
}
}
for (int i = 1; i < v.size(); i++) {
ans[v[0]][v[i]] = ans[v[i]][v[0]] = 1;
}
}
build(ans);
return 1;
}
Compilation message (stderr)
# | 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... |