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>
int par[1000];
using namespace std;
int findUpar(int node)
{
if(node==par[node])return node;
return findUpar(par[node]);
}
void Union(int u , int v)
{
int pu = findUpar(u) , pv = findUpar(v);
par[pu]=pv;
}
int construct(vector<vector<int>> p) {
int n = p.size();
for(int i=0 ; i<n ; i++)par[i]=i;
vector<vector<int>>ans(n,vector<int>(n));
for(int i=0 ; i<n ; i++)
{
for(int j=0 ; j<n ; j++)
{
if(p[i][j]==3)return 0;
if(p[i][j]==1)ans[i][j]=1,Union(i,j);
if(p[i][j]==2)
{
Union(i,j);
ans[findUpar(i)][findUpar(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... |