# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
684639 | Kongggwp | Connecting Supertrees (IOI20_supertrees) | C++14 | 1 ms | 300 KiB |
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);
if(pu==pv)return;
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(i==j)ans[i][j]=0;
if(p[i][j]==1)Union(i,j),ans[i][j]=1;
}
}
for(int i=0 ; i<n ; i++)
{
for(int j=0 ; j<n ; j++)
{
if(p[i][j]==2)
{
if(findUpar(i)!=findUpar(j))
ans[findUpar(i)][findUpar(j)] = 1;
}
}
}
for(int i=0 ; i<n ; i++)
ans[i][i]=0;
build(ans);
return 1;
}
Compilation message (stderr)
# | 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... |