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(vector<vector<int>> p)
{
int n = p.size();
// Subtask 2: line
// Subtask 3: circles
// Subtask 5: 0, 1, 2
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (p[i][j])
p[i][j] = 2;
}
}
for (int i = 0; i < n; i++)
p[i].push_back(i);
sort(p.begin(), p.end());
int l = 0, r = 1;
vector<vector<int>> answer(n, vector<int>(n));
while (r < n)
{
int i = 0;
for (; i < n; i++)
{
if (p[r][i] != p[r-1][i])
break;
}
if (i == n)
{
answer[p[r-1].back()][p[r].back()] = 1;
answer[p[r].back()][p[r-1].back()] = 1;
}
else
{
int sz = 0;
for (int j = 0; j < n; j++)
{
if (p[r-1][j])
sz++;
}
if (r - l != sz || r - l == 2)
return 0;
if (r - l > 2)
{
answer[p[r-1].back()][p[l].back()] = 1;
answer[p[l].back()][p[r-1].back()] = 1;
}
l = r;
}
r++;
}
if (l < n - 1)
{
int sz = 0;
for (int j = 0; j < n; j++)
{
if (p[r-1][j])
sz++;
}
if (r - l != sz || r - l == 2)
return 0;
if (r - l > 2)
{
answer[p[r-1].back()][p[l].back()] = 1;
answer[p[l].back()][p[r-1].back()] = 1;
}
}
build(answer);
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... |