{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003eLittle girl Susie accidentally found her elder brother\u0027s notebook. She has many things to do, more important than solving problems, but she found this problem too interesting, so she wanted to know its solution and decided to ask you about it. So, the problem statement is as follows.\u003c/p\u003e\n\u003cp\u003eLet\u0027s assume that we are given a \u003cspan class\u003d\"tex-font-style-bf\"\u003econnected\u003c/span\u003e weighted undirected graph \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eG\u003c/i\u003e \u003d (\u003ci\u003eV\u003c/i\u003e, \u003ci\u003eE\u003c/i\u003e)\u003c/span\u003e (here \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eV\u003c/i\u003e\u003c/span\u003e is the set of vertices, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eE\u003c/i\u003e\u003c/span\u003e is the set of edges). The shortest-path tree from vertex \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003c/span\u003e is such graph \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eG\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e \u003d (\u003ci\u003eV\u003c/i\u003e, \u003ci\u003eE\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e)\u003c/span\u003e that is a tree with the set of edges \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eE\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003c/span\u003e that is the subset of the set of edges of the initial graph \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eE\u003c/i\u003e\u003c/span\u003e, and the lengths of the shortest paths from \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003c/span\u003e to any vertex to \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eG\u003c/i\u003e\u003c/span\u003e and to \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eG\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003c/span\u003e are the same. \u003c/p\u003e\n\u003cp\u003eYou are given a \u003cspan class\u003d\"tex-font-style-bf\"\u003econnected\u003c/span\u003e weighted undirected graph \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eG\u003c/i\u003e\u003c/span\u003e and vertex \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003c/span\u003e. Your task is to find the shortest-path tree of the given graph from vertex \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003c/span\u003e, the total weight of whose edges is minimum possible.\u003c/p\u003e\n\u003cbr\u003e\n题意:给n个点m条边,两个点间无重边,然后是m行的ui,vi,wi代表起始点和边的权重(第几个代表第几条边)然后在给起始点u,问选哪些边,可以满足从起始点u到达其它点距离最短,且使整张图的权重最小;\u003cbr\u003e\n输出:所有边的总权重 以及选的边(递增顺序,若答案多组,输出任意一组)\n\u003cbr\u003e\n知识拓展\u003cbr\u003e\n最短路径树:概念就是以一个节点为根,然后根节点到其他所有点的距离最短,然后形成了一棵树,把不必要的边删除掉\u003cbr\u003e\n\n\u003cbr\u003e\n"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two numbers, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 3·10\u003csup class\u003d\"upper-index\"\u003e5\u003c/sup\u003e\u003c/span\u003e, \u003cspan class\u003d\"tex-span\"\u003e0 ≤ \u003ci\u003em\u003c/i\u003e ≤ 3·10\u003csup class\u003d\"upper-index\"\u003e5\u003c/sup\u003e\u003c/span\u003e) — the number of vertices and edges of the graph, respectively.\u003c/p\u003e\n\u003cp\u003eNext \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e lines contain three integers each, representing an edge — \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e, \u003ci\u003ev\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e, \u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e — the numbers of vertices connected by an edge and the weight of the edge (\u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≠ \u003ci\u003ev\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e, 1 ≤ \u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e\u003c/span\u003e). It is guaranteed that graph is connected and that \u003cspan class\u003d\"tex-font-style-bf\"\u003ethere is no more than one edge between any pair of vertices\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eThe last line of the input contains integer \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eu\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003eu\u003c/i\u003e ≤ \u003ci\u003en\u003c/i\u003e\u003c/span\u003e) — the number of the start vertex.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIn the first line print the minimum total weight of the edges of the tree.\u003c/p\u003e\n\u003cp\u003eIn the next line print the indices of the edges that are included in the tree, separated by spaces. The edges are numbered starting from \u003cspan class\u003d\"tex-span\"\u003e1\u003c/span\u003e in the order they follow in the input. You may print the numbers of the edges in any order.\u003c/p\u003e\n\u003cp\u003eIf there are multiple answers, print any of them.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3 3\u003cbr\u003e1 2 1\u003cbr\u003e2 3 1\u003cbr\u003e1 3 2\u003cbr\u003e3\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e2\u003cbr\u003e1 2 \u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4 4\u003cbr\u003e1 2 1\u003cbr\u003e2 3 1\u003cbr\u003e3 4 1\u003cbr\u003e4 1 2\u003cbr\u003e4\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e4\u003cbr\u003e2 3 4 \u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first sample there are two possible shortest path trees:\u003c/p\u003e\n\u003cul\u003e \n \u003cli\u003e with edges \u003cspan class\u003d\"tex-span\"\u003e1 – 3\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e2 – 3\u003c/span\u003e (the total weight is \u003cspan class\u003d\"tex-span\"\u003e3\u003c/span\u003e); \u003c/li\u003e\n \u003cli\u003e with edges \u003cspan class\u003d\"tex-span\"\u003e1 – 2\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e2 – 3\u003c/span\u003e (the total weight is \u003cspan class\u003d\"tex-span\"\u003e2\u003c/span\u003e); \u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eAnd, for example, a tree with edges \u003cspan class\u003d\"tex-span\"\u003e1 – 2\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e1 – 3\u003c/span\u003e won\u0027t be a shortest path tree for vertex \u003cspan class\u003d\"tex-span\"\u003e3\u003c/span\u003e, because the distance from vertex \u003cspan class\u003d\"tex-span\"\u003e3\u003c/span\u003e to vertex \u003cspan class\u003d\"tex-span\"\u003e2\u003c/span\u003e in this tree equals \u003cspan class\u003d\"tex-span\"\u003e3\u003c/span\u003e, and in the original graph it is \u003cspan class\u003d\"tex-span\"\u003e1\u003c/span\u003e.\u003c/p\u003e"}}]}