CF21D.Traveling Graph
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given undirected weighted graph. Find the length of the shortest cycle which starts from the vertex 1 and passes throught all the edges at least once. Graph may contain multiply edges between a pair of vertices and loops (edges from the vertex to itself).
输入格式
The first line of the input contains two integers n and m ( 1<=n<=15,0<=m<=2000 ), n is the amount of vertices, and m is the amount of edges. Following m lines contain edges as a triples x,y,w ( 1<=x,y<=n,1<=w<=10000 ), x,y are edge endpoints, and w is the edge length.
输出格式
Output minimal cycle length or -1 if it doesn't exists.
输入输出样例
输入#1
3 3 1 2 1 2 3 1 3 1 1
输出#1
3
输入#2
3 2 1 2 3 2 3 4
输出#2
14