#P6175. 无向图的最小环问题

无向图的最小环问题

Description

Given an undirected graph, find a cycle that contains at least 33 vertices, with no repeated vertices on the cycle, and whose total edge length is minimal. This problem is called the minimum cycle problem in an undirected graph. In this task, you need to output the total edge weight of the minimum cycle. If there is no solution, output No solution..

Input Format

The first line contains two positive integers n,mn, m, representing the number of vertices and the number of edges.

The next mm lines each contain three positive integers u,v,du, v, d, indicating that there is an edge of length dd between vertices uu and vv.

Output Format

Output the total edge weight of the cycle with the minimum total edge weight. If there is no solution, output No solution..

5 7
1 4 1
1 3 300
3 1 10
1 2 16
2 3 100
2 5 15
5 3 20
61

Hint

Sample explanation: one feasible solution is 135211-3-5-2-1.

For 20%20\% of the testdata, n,m10n, m \leq 10.

For 60%60\% of the testdata, m100m \leq 100.

For 100%100\% of the testdata, 1n1001 \le n \leq 100, 1m5×1031 \le m \leq 5 \times 10^3, 1d1051 \leq d \leq 10^5.

The output for no solution includes a period.

Translated by ChatGPT 5