Skip to content

Commit

Permalink
[update] 冗長なmergeの簡略化
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo314 committed Jun 29, 2024
1 parent 66ff501 commit cf3ee7c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/rerooting-dp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ std::vector<V> rerooting_dp(const Tree<Cost>& 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));
}
}
Expand Down

0 comments on commit cf3ee7c

Please sign in to comment.