# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
654580 | atigun | Stranded Far From Home (BOI22_island) | C++14 | 298 ms | 37996 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<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct dsu{
vector<int> parent;
vector<ll> sum;
vector<vector<int>> S;
int n;
dsu(int dsu_size) : n(dsu_size){
parent.resize(n+5);
iota(parent.begin(), parent.end(), 0);
sum.resize(n+5, 0);
S.resize(n+5);
}
int find(int v){
return parent[v] = (parent[v] == v ? v : find(parent[v]));
}
void merge(int v, int u){
if(S[find(u)].size() > S[find(v)].size())
swap(u, v);
if(find(u) == find(v))
return;
for(int x : S[find(u)])
S[find(v)].push_back(x);
S[find(u)].clear();
sum[find(v)]+= sum[find(u)];
parent[find(u)] = parent[find(v)];
}
# | 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... |