# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302902 | ivan24 | Connecting Supertrees (IOI20_supertrees) | C++14 | 262 ms | 22136 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>
using namespace std;
using ll = int;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define F first
#define S second
class UnionFind {
private:
ll n;
vi p,sz;
public:
UnionFind(ll n): n(n),p(n),sz(n,1){
for (ll i = 0; n > i; i++) p[i] = i;
}
ll root(ll x){
if (x != p[x]) p[x] = root(p[x]);
return p[x];
}
void unify (ll x, ll y){
x = root(x), y = root(y);
if(x == y) return;
if (sz[x] < sz[y]) swap(x,y);
p[y] = x; sz[x] += sz[y];
}
};
void build(vvi b);
int construct(vvi p) {
int n = p.size();
vvi ans(n,vi(n,0));
for (int i = 0; n > i; i++){
vi cur_set;
for (ll j = 0; n > j; j++){
if (p[i][j] != 0){
cur_set.push_back(j);
}
}
for (auto j: cur_set){
for (auto k: cur_set){
if (j == k) continue;
if (p[j][k] == 0) return 0;
else p[j][k] = 0;
}
}
for (ll j = 1; cur_set.size() > j; j++){
ans[i][cur_set[j]] = ans[cur_set[j]][i] = 1;
}
}
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... |