{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"Read problems statements in \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/LTIME33/mandarin/PAIRCLST.pdf\"\u003eMandarin Chinese \u003c/a\u003e, \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/LTIME33/russian/PAIRCLST.pdf\"\u003eRussian\u003c/a\u003e and \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/LTIME33/vietnamese/PAIRCLST.pdf\"\u003eVietnamese\u003c/a\u003e as well.\r\n\r\n\r\nYou are given a weighted graph with $N$ nodes and $M$ edges. Some of the nodes are marked as special nodes. Your task is to find the shortest pairwise distance between any two different special nodes.\r\n\r\n### Input\r\n- The first line of the input contains three space-separated integers $N$, $M$ and $K$ denoting the number of nodes, the number of edges, and the number of special nodes. \r\n- The next line contains $K$ space-separated distinct integers $A_{1}$, $A_{2}$, $\\ldots$, $A_{K}$, denoting the special nodes.\r\n- The next $M$ lines each contain three space-separated integers - $X$, $Y$, $Z$, denoting an edge connecting the nodes $X$ and $Y$, with weight $Z$.\r\n\r\n### Output\r\nOutput the shortest pairwise distance between any two different special nodes.\r\n\r\n### Constraints\r\n- The given graph is connected.\r\n- The given graph doesn\u0027t contain self loops and multiple edges.\r\n- $1 \\leq A_{i} \\leq N$\r\n- $1 \\leq Z_{j} \\leq 10^{4}$\r\n- $1 \\leq X_{j}, Y_{j} \\leq N$\r\n\r\n\r\n\r\n### Subtasks\r\n\r\n**Subtask #1 (20 points):** \r\n- $2 \\leq N \\leq 300$\r\n- $N-1 \\leq M \\leq \\frac{N \\cdot (N-1)}{2}$\r\n- $2 \\leq K \\leq N$\r\n\r\n\r\n**Subtask #2 (25 points):**\r\n- $2 \\leq N \\leq 10^5$\r\n- $N-1 \\leq M \\leq 10^5$\r\n- $2 \\leq K \\leq 10$\r\n\r\n\r\n**Subtask #3 (55 points):**\r\n- $2 \\leq N \\leq 10^5$\r\n- $N-1 \\leq M \\leq 3 \\cdot 10^5$\r\n- $2 \\leq K \\leq 10^4$"}},{"title":"Sample 1","value":{"format":"MD","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\u003e5 5 3\r\n1 3 5\r\n1 2 3\r\n2 3 4\r\n3 4 1\r\n4 5 8\r\n1 5 19\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\nNodes $1$, $3$, and $5$ are special nodes. Shortest distance between nodes $1$ and $3$ is $7$, and that between nodes $3$ and $5$ is $9$. Shortest distance between nodes $1$ and $5$ is $16$. Minimum of these distances is $7$. Hence answer is $7$."}}]}