#include "supertrees.h"
#include <vector>
using namespace std;
#define F first
#define S sedond
#define PB push_back
#define MP make_pair
#define P push
#define I insert
typedef long long ll;
typedef long l;
typedef unsigned long long ull;
int uni[1000];
int fin(int x){
if(uni[x]==x)return x;
else return fin(uni[x]);
}
void merg(int x,int y){
x=fin(x);
y=fin(y);
if(x<y)uni[y]=x;
else uni[x]=y;
}
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> answer;
for(int i=0;i<n;i++)uni[i]=i;
for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(p[i][j]==3)return 0;
vector<int> v1[n],v2[n];
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(p[i][j]==1 && fin(i)!=fin(j)){
answer[i][j]=answer[j][i]=1;
merg(i,j);
}
}
}
for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)if(p[i][j]!=1 && fin(i)==fin(j))return 0;
for(int i=0;i<n;i++){
int comsiz=1;
for(int j=i+1;j<n;j++){
if(p[i][j]==2 && fin(i)!=fin(j)){
answer[i][j]=answer[j][i]=1;
merg(i,j);
comsiz++;
}
}
if(comsiz==2)return 0;
}
for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)if(p[i][j]!=1 && fin(i)==fin(j))return 0;
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid number of rows in b |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid number of rows in b |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
428 KB |
WA in grader: Invalid number of rows in b |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid number of rows in b |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid number of rows in b |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid number of rows in b |
2 |
Halted |
0 ms |
0 KB |
- |