# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
479912 | glome | Connecting Supertrees (IOI20_supertrees) | C++17 | 0 ms | 0 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>
#include<bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
set<int> s;
bool ok = 1;
for (int i = 0; i<p.size(); i++) {
for (int j = 0; j<p.size(); j++) {
ok &= p[i][j];
s.insert(p[i][j]);
}
}
if(ok) {
vector<vector<int>> ans(p.size(), vector<int> (p.size()));
for (int i = 0; i<p.size(); i++) {
ans[i][i] = 0;
}
for (int i = 1; i<p.size(); i++) {
ans[0][i] = 1;
ans[i][0] = 1;
}
build(ans);
return 1;
}
if(s.size() == 2) {
vector<vector<int>> ans(p.size(), vector<int> (p.size(), 0))
for (int i = 0; i<p.size(); i++) {
for (int j = i + 1; j<p.size(); j++) {
if(p[i][j] == 1) {
ans[i][j] = 1;
ans[j][i] = 1;
}
}
}
build(ans);
return 1;
}
}