#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()
vector<bool>vis(1000,0);
vector<vector<int>>g;
vector<vector<int>>ans;
ll nn;
bool dfs1(int start,int beg)
{
vis[start]=1;
for(int i=0;i<nn;i++)
if(g[start][i]!=g[beg][i] && i!=start && i!=beg)
return 0;
for(int i=0;i<nn;i++)
if(!vis[i] && g[start][i])
{
ans[i][start]=1;
ans[start][i]=1;
return dfs1(i,beg);
}
return 1;
}
bool dfs2(int start,int beg)
{
vis[start]=1;
for(int i=0;i<nn;i++)
if(g[start][i]!=g[beg][i] && i!=start && i!=beg)
return 0;
ll count=0;
for(int i=0;i<nn;i++)
if(g[start][i])
count++;
if(count==2)
return 0;
for(int i=0;i<nn;i++)
if(!vis[i] && g[start][i])
{
ans[i][start]=1;
ans[start][i]=1;
return dfs2(i,beg);
}
ans[start][beg]=1;
ans[beg][start]=1;
return 1;
}
int construct(vector<vector<int>> pr)
{
nn=pr.size();
g=pr;
ans.assign(nn,vector<int>(nn,0));
for(int i=0;i<nn;i++)
{
bool now=dfs1(i,i);
if(!now)
return 0;
}
for(int i=0;i<nn;i++)
{
bool now=dfs2(i,i);
if(!now)
return 0;
}
for(int i=0;i<nn;i++)
ans[i][i]=0;
build(ans);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 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 |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |