typedef long long ll; typedef long double ld; #include using namespace std; #define int long long ll k; ll cpos(ll e, ll bin){ return (e<> n>>m>>k; vector r(k); map rr; for (int i = 0; i < k; i++) { std::cin >> r[i]; r[i]--; rr[r[i]]=i; } vector>> edges(n); for (int i = 0; i < m; i++) { ll a,b,c; std::cin >> a>>b>>c; a--;b--; edges[a].push_back({i, b,c}); edges[b].push_back({i, a,c}); } vector d(n<,vector>,greater>> pq; pq.push({0,0}); while(!pq.empty()){ auto [dis, pos] = pq.top();pq.pop(); ll bin = ((1<>k]) { auto [ind, nex, cost] = e; if(rr.find(ind)!=rr.end()){ if(d[cpos(nex, bin|(1<dis+cost){ d[cpos(nex, bin|(1< dis+cost){ d[cpos(nex, bin)] = dis+cost; pq.push({dis+cost, cpos(nex,bin)}); } } } } std::cout << d[cpos(n-1, (1<