{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eAn undirected graph is a graph in which the nodes are connected by undirected arcs. An undirected arc is an edge that has no arrow. Both ends of an undirected arc are equivalent--there is no head or tail. Therefore, we represent an edge in an undirected graph as a set rather than an ordered pair.\u003cbr\u003eNow given an undirected graph, you could delete any number of edges as you wish. Then you will get one or more connected sub graph from the original one (Any of them should have more than one vertex).\u003cbr\u003eYou goal is to make all the connected sub graphs exist the Hamiltonian circuit after the delete operation. What’s more, you want to know the minimum sum of all the weight of the edges on the “Hamiltonian circuit” of all the connected sub graphs (Only one “Hamiltonian circuit” will be calculated in one connected sub graph! That is to say if there exist more than one “Hamiltonian circuit” in one connected sub graph, you could only choose the one in which the sum of weight of these edges is minimum).\u003cbr\u003e\u0026nbsp;\u0026nbsp;For example, we may get two possible sums:\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/5b6b7527635c78d4f5a7410f8dc1ec13?v\u003d1715809570\"\u003e\u003c/center\u003e \u003cbr\u003e(1)\u0026nbsp;\u0026nbsp;7 + 10 + 5 \u003d 22\u003cbr\u003e(2)\u0026nbsp;\u0026nbsp;7 + 10 + 2 \u003d 19\u003cbr\u003e(There are two “Hamiltonian circuit” in this graph!)\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"In the first line there is an integer T, indicates the number of test cases. (T \u0026lt;\u003d 20)\u003cbr\u003eIn each case, the first line contains two integers n and m, indicates the number of vertices and the number of edges. (1 \u0026lt;\u003d n \u0026lt;\u003d1000, 0 \u0026lt;\u003d m \u0026lt;\u003d 10000)\u003cbr\u003eThen m lines, each line contains three integers a,b,c ,indicates that there is one edge between a and b, and the weight of it is c . (1 \u0026lt;\u003d a,b \u0026lt;\u003d n, a is not equal to b in any way, 1 \u0026lt;\u003d c \u0026lt;\u003d 10000)\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output “Case %d: “first where d is the case number counted from one. Then output “NO” if there is no way to get some connected sub graphs that any of them exists the Hamiltonian circuit after the delete operation. Otherwise, output the minimum sum of weight you may get if you delete the edges in the optimal strategy.\u003cbr\u003e\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n\r\n3 4\r\n1 2 5\r\n2 1 2\r\n2 3 10\r\n3 1 7 \r\n\r\n3 2\r\n1 2 3\r\n1 2 4\r\n\r\n2 2\r\n1 2 3\r\n1 2 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 19\r\nCase 2: NO\r\nCase 3: 6\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"In Case 1:\u003cbr\u003eYou could delete edge between 1 and 2 whose weight is 5. \u003cbr\u003e\u003cbr\u003eIn Case 2:\u003cbr\u003eIt’s impossible to get some connected sub graphs that any of them exists the Hamiltonian circuit after the delete operation."}}]}