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>
#include<bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
for(int i = 0;i<n;i++) {
for(int j = 0;j<n;j++) {
if(p[i][j] == 3 or p[i][j]!=p[j][i])return 0;
}
}
vector<vector<int>> ans(n,vector<int> (n,0));
{
vector<bool> vis(n);
vector<int> t;
for(int i = 0;i<n;i++) {
if(vis[i])continue;
vector<int> cur;
for(int j = 0;j<n;j++) {
if(p[i][j] == 1) {
cur.push_back(j);
vis[j]=1;
}
}
for(int j = 0;j<(int)cur.size()-1;j++) {
ans[cur[j]][cur[j+1]]=1;
ans[cur[j+1]][cur[j]]=1;
}
t.push_back(i);
}
for(int i = 0;i<n;i++)vis[i]=0;
vector<int> cur;
for(int j:t) {
cur.push_back(j);
}
for(int j=0;j<(int)cur.size()-1;j++) {
ans[cur[j]][cur[j+1]]=1;
ans[cur[j+1]][cur[j]]=1;
}
}
build(ans);
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... |