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)
{
bool sub1 = true;
int n = p.size();
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(p[i][j] != 1)
{
sub1 = false;
}
}
}
if(sub1)
{
vector<vector<int>> adjmatrix(n, vector<int> (n, 0));
for(int i = 0; i < n-1; i++)
{
adjmatrix[i][i+1] = 1;
adjmatrix[i+1][i] = 1;
}
build(adjmatrix);
return 1;
}
//sub2
vector<vector<int>> adjmatrix(n, vector<int> (n, 0));
vector<bool> used(n, false);
for(int i = 0; i < n; i++)
{
if(!used[i])
{
vector<int> nodes(0);
for(int j = 0; j < n; j++)
{
if(p[i][j] == 1)
{
nodes.push_back(j);
used[j] = true;
}
}
for(int i : nodes)
{
if(count(adjmatrix[i].begin(), adjmatrix[i].end(), 1) != (int) nodes.size())
{
return 0;
}
for(int j : nodes)
{
if(p[i][j] != 1)
{
return 0;
}
}
}
for(int i = 0; i < (int) nodes.size()-1; i++)
{
adjmatrix[nodes[i]][nodes[i+1]] = 1;
adjmatrix[nodes[i+1]][nodes[i]] = 1;
}
}
}
build(adjmatrix);
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... |