Graph and Minimum Spanning Tree
Time limit2sMemory limit512 MB
For each edge of a connected weighted undirected graph, print the weight of a minimum spanning tree that is forced to include that edge.
- Level
Hard8 of 10
- Topics
- Minimum spanning tree, Union-find, Tree, DFS
- Solved
- No attempts yet
Problem
You are given a connected, undirected, weighted graph with vertices and edges. has no self-loops, and at most one edge joins any pair of vertices.
For each edge , compute the total weight of a minimum spanning tree that is forced to contain that edge.
Input
The first line contains the number of vertices and the number of edges (, ).
Each of the next lines contains the edge information , , , meaning that the edge joining vertex and vertex has weight (, , ).
Output
For each edge, print the total weight of a minimum spanning tree containing that edge, one per line. Print the answers in the order the edges are given in the input.