# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377331 | autumn_eel | Connecting Supertrees (IOI20_supertrees) | C++14 | 337 ms | 24300 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 <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
struct UnionFind{
vector<int>par;
UnionFind(int n){
par=vector<int>(n);
rep(i,n)par[i]=i;
}
int find(int x){
return par[x]==x?x:par[x]=find(par[x]);
}
void unite(int x,int y){
x=find(x);y=find(y);
par[x]=y;
}
bool same(int x,int y){
return find(x)==find(y);
}
};
static vector<int>v[2000];
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n);
answer.push_back(row);
}
UnionFind uf(n);
rep(i,n)rep(j,n){
if(p[i][j])uf.unite(i,j);
}
rep(i,n){
v[uf.find(i)].push_back(i);
}
rep(i,n)rep(j,n){
if(i==j)continue;
if(uf.same(i,j)&&!p[i][j])return 0;
}
rep(i,n){
if(v[i].size()>1){
rep(j,v[i].size()-1){
answer[v[i][j]][v[i][j+1]]=1;
answer[v[i][j+1]][v[i][j]]=1;
}
}
}
build(answer);
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... |