LAN
Maximum Sum of Removed Network Cables
In a local area network, there are n computers and k bidirectional network cables. The computers are numbered from 1 to n. Due to negligence during setup, the connections in the network form cycles. We know that if cycles exist in the network, data will continuously transmit within the cycles, causing network lag.
Note:
- For any connection, although it is bidirectional, we do not consider a single connection as a cycle. A cycle described in this problem must contain at least two distinct connections.
- There is at most one connection between any two computers.
- No connection has both ends connected to the same computer.
Because the network cables are different, some connections are more smooth than others. We use f(i, j) to represent the smoothness of the connection between i and j. A smaller f(i, j) value indicates a more smooth connection between i and j.
Now we need to resolve the cycle issue. We will remove some cables such that there are no cycles in the network while maintaining connectivity (i.e., if two points were connected before removal, they must remain connected after removal). The goal is to maximize the sum Σf(i, j) of the removed cables. Find this maximum value.
Input Format
The first line contains two positive integers n, k.
The next k lines each contain three positive integers i, j, m, indicating that there is a network cable between computers i and j with smoothness m.
Output Format
A single positive integer representing the maximum value of Σf(i, j) for the removed cables.
Constraints
1 ≤ n ≤ 100
0 ≤ k ≤ 200
1 ≤ f(i, j) ≤ 1000
Sample Input
5 5
1 2 8
1 3 1
1 5 3
2 4 5
3 4 2
Sample Output
8
Comments