# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289217 | dolphingarlic | Swapping Cities (APIO20_swap) | C++14 | 482 ms | 55592 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;
pair<int, pair<int, int>> edges[200000];
int cmp[300000], deg[300000], cost[300000], nodes;
bool has_deg_3[300000], has_cycle[300000];
vector<int> dsu_tree[300000];
int tin[300000], tout[300000], timer = 0, anc[300000][20];
int find(int A) {
while (A != cmp[A]) A = cmp[A], cmp[A] = cmp[cmp[A]];
return A;
}
void onion(int A, int B) {
has_cycle[nodes] = has_cycle[find(A)] || has_cycle[find(B)];
if (find(A) == find(B)) has_cycle[nodes] = true;
has_deg_3[nodes] = has_deg_3[find(A)] || has_deg_3[find(B)];
if (deg[A] == 3 || deg[B] == 3) has_deg_3[nodes] = true;
dsu_tree[nodes].push_back(find(A));
if (find(A) != find(B)) dsu_tree[nodes].push_back(find(B));
cmp[find(A)] = cmp[find(B)] = nodes;
nodes++;
}
void dfs(int node = nodes - 1, int parent = -1) {
tin[node] = timer++;
for (int i = 1; i < 20; i++) anc[node][i] = -1;
# | 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... |