# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574165 | MilosMilutinovic | Stranded Far From Home (BOI22_island) | C++14 | 252 ms | 36804 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;
const int N = 200005;
int n, m, s[N], fa[N], mx[N], ans[N];
long long sum[N];
vector<int> g[N], ch[N];
int getfa(int x) {
return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
void unite(int x, int y) {
x = getfa(x);
y = getfa(y);
if (x == y)
return;
if (sum[x] < mx[y])
ch[x].clear();
if (mx[x] > sum[y])
ch[y].clear();
if (ch[x].size() < ch[y].size())
swap(x, y);
for (int i : ch[y])
ch[x].push_back(i);
fa[y] = x;
mx[x] = max(mx[x], mx[y]);
sum[x] += sum[y];
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> m;
# | 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... |