#P17641. [ICPC 2019 Yinchuan R] Toad's Travel

    ID: 20146 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>动态规划 DP2019最短路Tarjan双连通分量仙人掌ICPC圆方树

[ICPC 2019 Yinchuan R] Toad's Travel

Problem Description

A toad is travelling in Byteland, which consists of some cities and some roads, each of which connects a pair of cities. More specifically, the map of Byteland is an undirected connected edge-weighted graph in which every edge lies on at most one simple cycle. The toad is in the city numbered by 11 at first and wants to go through all the roads at least once.

TIME IS MONEY!

The toad must minimize the total length of the path in his travelling.

Input Format

The first line contains two integers n,m (2≤n≤105,n−1≤m≤2n−2)n,m~(2 \le n\le 10^5,n-1\leq m\leq 2n-2), indicates the number of cities and roads in Byteland.

Each of the next mm lines contains three integers $u_i, v_i, w_i~(1 \le u_i, v_i \le n, u_i \ne v_i, 0 \le w_i \le 10^5)$, representing a road with a length of wiw_i connects uiu_i and viv_i. It's guaranteed that each pair of cities will be connected with at most one road.

Output Format

Output a single integer, indicating the minimum possible sum.

6 7
1 2 1
1 3 1
2 3 1
3 4 1
3 5 1
4 5 1
2 6 1
8

Hint

In the sample test, one of the best paths is

$$\displaystyle 1\rightarrow2\rightarrow6\rightarrow2\rightarrow3\rightarrow4\rightarrow5\rightarrow3\rightarrow1$$

and the total length of the path is 88.