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 <bits/stdc++.h>
using namespace std;
int construct(vector<vector<int>> p) {
int N = p.size();
vector<int> group(N,-1);
bool vis[N]{};
vector<vector<int>> answer(N);
for(int i = 0; i < N; i++) {
answer[i].assign(N,0);
}
int prev;
for (int i = 0; i < N; i++) {
if(!vis[i]) {
prev = i;
vis[i] = true;
group[i] = i;
for(int j = 0; j < N; j++) {
if(i != j && p[i][j]) {
if(vis[j]) return 0;
vis[j] = true;
answer[prev][j] = answer[j][prev] = 1;
group[j] = i;
prev = j;
}
}
answer[prev][i] = answer[i][prev] = 1;
}
}
/*for(int i = 0; i < connectedGroups.size(); i++) {
cout << i << ":\n";
for(auto x: connectedGroups[i])
cout << x << endl;
}*/
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if((i != j) && ((group[i] == group[j]) != (p[i][j] == 2))) {
return 0;
}
}
}
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... |