#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]==0&&a[node][i]>nr&&a[node][i]!=0){
dfs(i,nr);
}
}
}
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 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:63: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]
63 | for(ll j=1;j<v.size();j++)
| ~^~~~~~~~~
supertrees.cpp:97: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]
97 | for(ll j=0;j<x.size();j++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Incorrect |
1 ms |
384 KB |
Answer gives possible 0 while actual possible 1 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |