#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int pa[N];
bool cy[N][N];
set<int> s;
int root(int x){
if(pa[x]==x) return x;
else return pa[x]=root(pa[x]);
}
int construct(vector<vector<int> > p) {
int n = p.size();
vector<vector<int> > answer;
for (int i = 0; i < n; i++) {
vector<int> row(n,0);
answer.push_back(row);
}
for(int i=0;i<n;i++) pa[i]=i;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(p[i][j]==1 && root(i)!=root(j)){
answer[i][j]=1;
answer[j][i]=1;
pa[root(i)]=root(j);
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int a,b;
if(p[i][j]==2){
a=root(i),b=root(j);
s.insert(a);
s.insert(b);
}
}
}
int prev=*s.begin(),first=*s.begin();
for(set<int>::iterator it=s.begin();it!=s.end();it++){
if(it==s.begin()) continue;
answer[*it][prev]=1;
answer[prev][*it]=1;
prev=*it;
}
answer[first][*s.end()]=1;
answer[*s.end()][first]=1;
build(answer);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |