#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int parent[1001],siz[1001];
void initial()
{
for(int i=0;i<1001;i++)
{
siz[i]=1;
parent[i]=i;
}
}
int findd(int a)
{
if(a==parent[a])return a;
return parent[a]=findd(parent[a]);
}
bool unionn(int a,int b)
{
a=findd(a);
b=findd(b);
if(a!=b)
{
if(siz[a]<siz[b])swap(a,b);
parent[b]=a;
siz[a]+=siz[b];
return 1;
}
return 0;
}
int construct(vector<vector<int> > p) {
initial();
int n = p.size();
vector<vector<int> > answer(n, vector<int>(n, 0));
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(p[i][j]==3)return 0;
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
answer[i][j]=p[i][j],answer[j][i]=p[j][i];
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
if(p[i][j]==0 && !unionn(i,j))
return 0;
build(answer);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
496 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Answer gives possible 0 while actual possible 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |