# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
603753 | lcj | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 212 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#include "supertrees.h"
#define con(a, b) answer[a][b] = 1;answer[b][a] = 1;
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> answer(n, vector<int>(n, 0));
vector<vector<int>> groups;
vector<bool> assigned(n, 0);
for (int i = 0; i < n; i++)
{
if (assigned[i]) continue;
vector<int> cgroup;
for (int j = 0; j < n; j++)
{
if (p[i][j] == 0) continue;
if (assigned[j]) {
return 0;
}
cgroup.push_back(j);
assigned[j] = 1;
}
groups.push_back(cgroup);
}
for (auto &g : groups) {
vector<vector<int>> branches;
vector<bool> br(n, 0);
for (int i : g) {
if (br[i]) continue;
vector<int> branch;
for (int j : g) {
if (p[i][j] == 2) continue;
if (br[j]) return 0;
branch.push_back(j);
br[j] = 1;
}
branches.push_back(branch);
}
for (int i = 0; i < branches.size(); i++)
{
con(branches[i][0], branches[(i+1)%branches.size()][0])
for (int j = 0; j < branches[i].size()-1; j++)
{
con(branches[i][j], branches[i][j+1])
}
}
}
build(answer);
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... |