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;
const int N = 1e3 + 7;
int nn, comp, used[N];
set < int > cmp[N];
void rec( int v, vector<std::vector<int>> p ) {
//cout << v << endl;
cmp[ comp ].insert(v);
used[v] = 1;
for ( int i = 0; i < nn; i++ ) {
if ( p[v][i] && !used[i] ) {
rec( i, p );
}
}
}
int construct(std::vector<std::vector<int>> p) {
nn = p.size();
std::vector<std::vector<int>> answer;
for (int i = 0; i < nn; i++) {
std::vector<int> row;
row.resize(nn);
answer.push_back(row);
}
for ( int i = 0; i < nn; i++ ) {
if ( used[i] ) {
continue;
}
comp++;
rec( i, p );
}
for ( int i = 1; i <= comp; i++ ) {
vector < int > vc;
for ( auto j: cmp[i] ) {
vc.push_back( j );
}
for ( int i = 0; i < (int)vc.size() - 1; i++ ) {
answer[ vc[i] ][ vc[i + 1] ] = 1;
answer[ vc[i + 1] ][ vc[i] ] = 1;
}
for ( auto x1: vc ) {
for ( auto x2: vc ) {
if ( !p[x1][x2] ) {
return 0;
}
}
}
}
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... |