#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int nax=1e3+3;
int alt[nax];
int link[nax];
int find(int a){
if(link[a]==a)return a;
return link[a]=find(link[a]);
}
void unite(int a,int b){
int x=find(a);
int y=find(b);
if(x==y)return;
if(alt[x]>alt[y])link[y]=x;
else{
link[x]=y;
if(alt[x]==alt[y])alt[y]++;
}
}
bool same(int a, int b){
return find(a)==find(b);
}
int construct(std::vector<std::vector<int>> p){
int n=p.size();
vector<vector<int>> b(n,vector<int>(n));
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++){
if(p[i][j]==1&&!same(i,j)){
unite(i,j);
b[i][j]=1;
b[j][i]=1;
}
}
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)if(same(i,j)&&p[i][j]==0)return 0;
build(b);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Answer gives possible 0 while actual possible 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Answer gives possible 0 while actual possible 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |