# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302982 | dolijan | Connecting Supertrees (IOI20_supertrees) | C++14 | 3 ms | 640 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>
using namespace std;
const int mn=1100;
vector<int> parent(mn);
vector<int> velicina(mn);
int find_parent(int node)
{
if(parent[node]==node) return node;
return parent[node]=find_parent(parent[node]);
}
int join(int a,int b)
{
int pa=find_parent(a);
int pb=find_parent(b);
if(velicina[pa]<velicina[pb])
{
parent[pa]=pb;
velicina[pb]+=velicina[pa];
}
else
{
parent[pb]=pa;
velicina[pa]+=velicina[pb];
}
}
int construct(std::vector<std::vector<int> > p) {
int n=p.size();
vector<vector<int> > b(n);
for(int i=0;i<n;i++)
{
parent[i]=i;
velicina[i]=1;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++) b[i].push_back(false);
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(p[i][j]==1 && find_parent(i)!=find_parent(j))
{
b[i][j]=b[j][i]=true;
join(i,j);
}
else
{
if(find_parent(i)==find_parent(j)) return 0;
}
}
}
build(b);
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... |