0-1 MST
HardRating 1900CodeforcesGraph Theory (MST, SCC, Bridges)
Approach hintTry it first, then revealHide
The MST weight equals the number of components formed by the weight-0 edges, minus one. Find those components in the complement graph with a BFS that keeps unvisited vertices in a set and skips weight-1 neighbours.