Skip to content

Commit cae4bc5

Browse files
committed
first draft
1 parent ec7f5bb commit cae4bc5

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
//! https://mzhang2021.github.io/cp-blog/kruskal/
3+
//! @time O(n log n)
4+
//! @space O(n)
5+
struct kr_tree {
6+
int id;
7+
vi p;
8+
vector<vi> adj;
9+
kr_tree(int n): id(n), p(2 * n, -1), adj(2 * n) {}
10+
int f(int v) { return p[v] < 0 ? v : p[v] = f(p[v]); }
11+
bool join(int u, int v) {
12+
if ((u = f(u)) == (v = f(v))) return 0;
13+
return adj[p[u] = p[v] = id++] = {u, v}, 1;
14+
}
15+
};

tests/library_checker_aizu_tests/dsu/kruskal_tree_aizu.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#define PROBLEM \
22
"https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_12_A"
33
#include "../template.hpp"
4-
#include "../../../library/dsu/kruskal_tree.hpp"
4+
#include "../../../library/dsu/kruskal_tree_linear_height.hpp"
55
int main() {
66
cin.tie(0)->sync_with_stdio(0);
77
int n;

tests/library_checker_aizu_tests/dsu/line_tree_lib_checker.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"https://judge.yosupo.jp/problem/minimum_spanning_tree"
33
#include "../template.hpp"
44
#include "../../../library/dsu/line_tree.hpp"
5-
#include "../../../library/dsu/kruskal_tree.hpp"
5+
#include "../../../library/dsu/kruskal_tree_linear_height.hpp"
66
int main() {
77
cin.tie(0)->sync_with_stdio(0);
88
int n, m;

0 commit comments

Comments
 (0)