# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
684015 | thiago_bastos | Swapping Cities (APIO20_swap) | C++17 | 124 ms | 12180 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 "swap.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int par[MAXN], depth[MAXN], t[MAXN], third[MAXN], deg[MAXN];
int findSet(int u) {
return u == par[u] ? u : findSet(par[u]);
}
int h(int u) {
return u == par[u] ? 0 : 1 + h(par[u]);
}
void merge(int u, int v, int w) {
int a = findSet(u);
int b = findSet(v);
if(depth[a] > depth[b]) swap(a, b);
++deg[u], ++deg[v];
if(a == b) third[a] = min(third[a], w);
else {
par[a] = b;
depth[b] += depth[a] == depth[b];
int x = max(w, third[a]), y = max(w, third[b]);
if(max(deg[u], deg[v]) > 2) x = min(x, w), y = min(y, w);
t[a] = w;
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... |