From 4d51e80a3f9acf7b90a9de95a70b84a790336166 Mon Sep 17 00:00:00 2001 From: OmeletWithoutEgg <2qbingxuan@gmail.com> Date: Tue, 30 Jan 2024 00:13:53 +0800 Subject: [PATCH] Update lowbit decomposition --- codes/Graph/LowbitDecomposition.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/codes/Graph/LowbitDecomposition.cpp b/codes/Graph/LowbitDecomposition.cpp index 768b486c..939ad633 100644 --- a/codes/Graph/LowbitDecomposition.cpp +++ b/codes/Graph/LowbitDecomposition.cpp @@ -28,12 +28,10 @@ class LBD { tr[u] = timer; } public: - LBD(int n) : timer(0), chains(0), G(n), tl(n), tr(n), - chain(n), head(n + 1, -1), dep(n), pa(n) {} - void add_edge(int u, int v) { - G[u].push_back(v); G[v].push_back(u); - } - void decompose() { predfs(0, 0); dfschain(0, 0); } + LBD(auto &&G_) : n((int)size(G_)), + timer(0), chains(0), G(G_), tl(n), tr(n), + chain(n), head(n + 1, -1), dep(n), pa(n) + { predfs(0, 0); dfschain(0, 0); } PII get_subtree(int u) { return {tl[u], tr[u]}; } vector get_path(int u, int v) { vector res; @@ -48,4 +46,4 @@ class LBD { res.emplace_back(tl[v], tl[u] + 1); return res; } -}; +}; // 記得在資結上對點的修改要改成對其 dfs 序的修改