Minimum spanning tree for each edge
HardRating 2100CodeforcesGraph Theory (MST, SCC, Bridges)
Approach hintTry it first, then revealHide
Build one MST. Forcing edge (u, v, w) into the tree means dropping the heaviest MST edge on the path between u and v, so the answer is MST - maxOnPath + w; answer path maxima with binary lifting.