This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "supertrees.h"
#include <vector>
using namespace std;
#define add push_back
#define len(a) ((int)(a).size())
int construct(vector<vector<int>> p) {
vector<vector<int>> answer(len(p));
vector<int> h(len(p));
vector<int> v[1005];
int now = 0;
for(int i = 0; i < len(p); i++){
answer[i].resize(len(p));
for(int j = 0; j < i; j++){
if(p[i][j] != 0){
h[i] = h[j];
break;
}
}
if(h[i] == 0){
h[i] = ++now;
}
v[h[i]].add(i);
}
for(int i = 0; i < len(p); i++){
for(int j = i + 1; j < len(p); j++){
if(p[i][j] != 0 && h[i] != h[j]){
return 0;
}
}
}
for(int i = 1; i <= now; i++){
for(int j = 1; j < len(v[now]); j++){
answer[v[now][j]][v[now][j - 1]] = answer[v[now][j - 1]][v[now][j]] = 1;
}
}
build(answer);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |