Line Graph Matching
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

In the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph G is another simple undirected weighted graph L(G) that represents the adjacency between every two edges in G.

Precisely speaking, for an undirected weighted graph G without loops or multiple edges, its line graph L(G) is an undirected weighted graph such that:
Each vertex of L(G) represents an edge of G;
Two vertices of L(G) are adjacent if and only if their corresponding edges share a common endpoint in G, and the weight of such edge between this two vertices is the sum of the weights of their corresponding edges.



A maximum weighted matching in a simple undirected weighted graph is defined as a set of edges where no two edges share a common vertex and the sum of the weights of the edges in the set is maximized.

Given a simple undirected weighted connected graph G, your task is to find the sum of the weights of the edges in the maximum weighted matching of L(G).

输入描述:

The first line contains two integers n  and m , indicating the number of vertices and edges in the given graph G.

Then follow m lines, the i-th of which contains three integers u, v and w , indicating that the i-th edge in the graph G has a weight of w and connects the u-th and the v-th vertices. It is guaranteed that the graph G is connected and contains no loops and no multiple edges.

输出描述:

Output a line containing a single integer, indicating the sum of the weights of the edges in the maximum weighted matching of L(G).
示例1

输入

复制
5 6
1 2 1
1 3 2
1 4 3
4 3 4
4 5 5
2 5 6

输出

复制
21
示例2

输入

复制
6 5
1 2 4
2 3 1
3 4 3
4 5 2
5 6 5

输出

复制
12
示例3

输入

复制
5 5
1 2 1
2 3 2
3 4 3
4 5 4
5 1 5

输出

复制
14