# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
850467 | MinaRagy06 | Stranded Far From Home (BOI22_island) | C++17 | 1045 ms | 524288 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 int64_t ll;
const int N = 200'005;
int par[N], sz[N], bad[N];
ll cnt[N], a[N];
vector<int> adj[N];
pair<int, int> find(int u) {
if (par[u] == u) {
return {u, bad[u]};
}
pair<int, int> v = find(par[u]);
bad[u] |= v.second;
par[u] = v.first;
return {par[u], bad[u]};
}
void join(int u, int v) {
u = find(u).first, v = find(v).first;
if (u == v) return;
par[v] = u, sz[u] += sz[v], cnt[u] += cnt[v];
for (auto nxt : adj[v]) {
int x = find(nxt).first;
if (x != u) {
adj[u].push_back(nxt);
}
}
adj[v].clear();
}
int main() {
# | 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... |