From cf3ee7c2cc82cc9c310d2a7c87a5658a4d2275ea Mon Sep 17 00:00:00 2001 From: shogo314 Date: Sat, 29 Jun 2024 13:20:16 +0900 Subject: [PATCH] =?UTF-8?q?[update]=20=E5=86=97=E9=95=B7=E3=81=AAmerge?= =?UTF-8?q?=E3=81=AE=E7=B0=A1=E7=95=A5=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/rerooting-dp.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/rerooting-dp.hpp b/cpp/rerooting-dp.hpp index 9d8dec9..bc62bd6 100644 --- a/cpp/rerooting-dp.hpp +++ b/cpp/rerooting-dp.hpp @@ -44,9 +44,9 @@ std::vector rerooting_dp(const Tree& tree, E e, Merge merge, AddEdge ad ri[i - 1] = merge(ri[i], addedge(subdp[ch[i - 1].dst], ch[i - 1].cost, ch[i - 1].id)); } dp[u] = addnode(merge(pe[u], ri[0]), u); - E le = e; + E le = pe[u]; for (size_t i = 0; i < ch.size(); i++) { - pe[ch[i].dst] = addedge(addnode(merge(pe[u], merge(le, ri[i + 1])), u), ch[i].cost, ch[i].id); + pe[ch[i].dst] = addedge(addnode(merge(le, ri[i + 1]), u), ch[i].cost, ch[i].id); le = merge(le, addedge(subdp[ch[i].dst], ch[i].cost, ch[i].id)); } }