# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <vector> # include <queue> using namespace std; const int INF = 0x7fffffff; const int maxn = 1100; struct Edge {int from, to, dist ;}; // struct HeapNode {int d, u; bool operator <(const HeapNode & rhs) const {return d> rhs. d ;}}; int n, m; // point, edgevector <Edge> edges; vector <int> G [maxn]; bool done [maxn]; int d [maxn]; // int P [maxn]; int term [maxn]; void init () {for (int I = 0; I <maxn; I ++) G [I]. clear (); // The node number starts from 1. Edges. clear (); // memset (p, 0, sizeof (p);} void AddEdge (int from, int to, int dist) {// note that it is an undirected graph, WA has been used many times. Edges. push_back (Edge) {from, to, dist}); m = edges. size (); // edges G [from]. push_back (m-1); // number each side from 0 .} Void Dijkstra () {priority_queue <HeapNode> Q; for (int I = 0; I <= maxn; I ++) {// n, the node number is not n d [I] = INF;} d [0] = 0; // use the node as the super source. Memset (done, 0, sizeof (done); Q. push (HeapNode) {0, 0}); // d, u while (! Q. empty () {HeapNode x = Q. top (); Q. pop (); int u = x. u; if (done [u]) continue; done [u] = true; // mark that one already exists. The vertex that has been accessed and is in the solution for (int I = 0; I <(int) G [u]. size (); I ++) {Edge & e = edges [G [u] [I]; if (d [e. to]> d [u] + e. dist) {d [e. to] = d [u] + e. dist; // p [e. to] = G [u] [I]; // record the ID of the precursor node. Q. push (HeapNode) {d [e. to], e. to}) ;}}} int main () {int T, S, D; n = maxn; while (scanf ("% d", & T, & S, & D )! = EOF) {// start, destination init (); for (int I = 0; I <T; I ++) {int from, to, dist; scanf ("% d", & from, & to, & dist); AddEdge (from, to, dist); AddEdge (to, from, dist );} for (int I = 0; I <S; I ++) {int to; scanf ("% d", & to); AddEdge (0, to, 0 );} for (int I = 0; I <D; I ++) {scanf ("% d", & term [I]);} Dijkstra (); int res = INF; for (int I = 0; I <D; I ++) {if (d [term [I] <res) res = d [term [I];} printf ("% d \ n", res);} return 0 ;}