eolymp
bolt
Try our new interface for solving problems
Problems

Minimum spanning tree

Minimum spanning tree

Find the weight of minimum spanning tree for a weighted undirected connected graph. \InputFile The first line contains the numbers $n$ and $m~(1 \le n \le 100, 1 \le m \le 6000)$, where $n$ is the number of vertices in the graph and $m$ is the number of edges. Each of the next $m$ lines contains a triple of integers $a, b, c$, where $a$ and $b$ are the numbers of vertices connected by an edge and $c$ is the weight of edge (a positive number not exceeding $30000$). \OutputFile Print the weight of minimum spanning tree. \includegraphics{https://static.e-olymp.com/content/24/24e3c2f937536a69220a9b6813b3830b615ce533.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
3 3
1 2 1
2 3 2
3 1 3
Output example #1
3