#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#include "supertrees.h"
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[2005][2005],ans[2005][2005],pos[2005],viz[2005];
vector<ll>v;
void dfs(ll node,ll nr){
viz[node]=1;
v.pb(node);
for(ll i=0;i<n;i++)
{
if(viz[i]||a[node][i]>c||a[node][i]==0){
continue;
}
dfs(i,c);
}
}
int construct(vector<vector<int>>p){
n=p[0].size();
for(ll i=0;i<n;i++)
{
for(ll j=0;j<n;j++)
{
a[i][j]=p[i][j];
}
}
for(ll i=0;i<n;i++)
{
if(viz[i]){
continue;
}
v.clear();
dfs(i,1ll);
for(auto it1 : v){
for(auto it2: v){
if(a[it1][it2]!=1){
return 0;
}
}
}
for(auto it : v){
pos[it]=v[0];
}
for(ll j=1;j<v.size();j++)
{
ans[v[j]][v[j-1]]=1;
ans[v[j-1]][v[j]]=1;
}
}
memset(viz,0,sizeof(viz));
for(ll i=0;i<n;i++)
{
if(viz[i]){
continue;
}
v.clear();
dfs(i,2);
for(auto it1 : v){
for(auto it2 : v){
if(a[it1][it2]==0){
return 0;
}
}
}
vector<ll>x;
for(auto it : v){
if(pos[it]==it){
x.pb(it);
}
}
if(x.size()<=1){
continue;
}
if(x.size()==2){
return 0;
}
for(ll j=0;j<x.size();j++)
{
ll nr=x.size();
ll s1=x[j],s2=x[(j+1)%nr];
ans[s1][s2]=1;
ans[s2][s1]=1;
}
}
vector<vector<int>>res;
res.resize(n);
for(ll i=0;i<n;i++)
{
for(ll j=0;j<n;j++)
{
res[i].pb(ans[i][j]);
}
}
build(res);
return 1;
}
/*
int32_t main(){
CODE_START;
*/
Compilation message
supertrees.cpp: In function 'void dfs(long long int, long long int)':
supertrees.cpp:32:26: error: 'c' was not declared in this scope
32 | if(viz[i]||a[node][i]>c||a[node][i]==0){
| ^
supertrees.cpp:35:10: error: 'c' was not declared in this scope
35 | dfs(i,c);
| ^
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:64:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(ll j=1;j<v.size();j++)
| ~^~~~~~~~~
supertrees.cpp:98:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
98 | for(ll j=0;j<x.size();j++)
| ~^~~~~~~~~