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 pa[2005];
int fp(int u) {return (u == pa[u]) ? u : pa[u] = fp(pa[u]);}
int construct(vector<vector<int>> p)
{
int n = p.size();
for(int i=0 ; i<n+n ; i++)
pa[i] = i;
for(int i=0 ; i<n ; i++)
for(int j=i+1 ; j<n ; j++)
{
if(p[i][j] == 3) return 0;
else if(p[i][j])
{
pa[fp(i)] = fp(j);
pa[fp(i+n)] = fp(j+n);
}
else
{
pa[fp(i)] = fp(j+n);
pa[fp(i+n)] = fp(j);
}
}
for(int i=0 ; i<n ; i++)
if(fp(i) == fp(i+n)) return 0;
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... |