{"trustable":false,"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":"MD","content":"这是一个非常容易解决的问题,您的任务只是计算grafica的价格,而只是计算干草地的价格。 如果您不懂此段话,请继续。\nNya图是具有“层”的无向图。 图中的每个节点都属于一个层,总共有N个节点。\n您可以以成本C从x层中的任何节点移动到x + 1层中的任何节点,因为道路是双向的,因此也可以以相同的成本从x + 1层移动到x层。\n此外,还有M个额外的边,每个边连接一对节点u和v,成本为w。\n帮助我们计算从节点1到节点N的最短路径。"}},{"title":"Input","value":{"format":"MD","content":"第一行的数字为T(T \u003c\u003d 20),表示测试用例的数量。\n对于每个测试用例,第一行具有三个数字N,M(0 \u003c\u003d N,M \u003c\u003d 105)和C(1 \u003c\u003d C \u003c\u003d 103),这是节点数,额外边数和成本 在相邻层之间移动的过程。\n第二行具有N个数字li(1 \u003c\u003d li \u003c\u003d N),这是第i个节点所属的层。\n然后是N行,每行有3个数字,分别是u,v(1 \u003c\u003d u,v \u003c\u003d N,u \u003c\u003e v)和w(1 \u003c\u003d w \u003c\u003d 104),这意味着有一个额外的边,连接一个 一对节点u和v,成本为w。"}},{"title":"Output","value":{"format":"MD","content":"For test case X, output \"Case #X: \" first, then output the minimum cost moving from node 1 to node N.\n\u003cbr\u003eIf there are no solutions, output -1."}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e2\n3 3 3\n1 3 2\n1 2 1\n2 3 1\n1 3 3\n\n3 3 3\n1 3 2\n1 2 2\n2 3 2\n1 3 4\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003eCase #1: 2\nCase #2: 3\u003c/pre\u003e"}}]}