#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; // g <- pair < v , cost > template < class T > vector< T > dijkstra(vector>> &graph, int s) { T INF = numeric_limits< T >::max(); vector dist(graph.size(), INF); priority_queue, vector>, greater>> q; q.push({dist[s] = T(0), s}); while(!q.empty()){ auto [uc, ui] = q.top(); q.pop(); if(uc != dist[ui]) continue; for(auto [vi, vc] : graph[ui]) if(dist[vi] > uc + vc) q.push({dist[vi] = uc + vc, vi}); } return dist; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M,K; cin >> N >> M >> K; vector R(K); rep(i,K) cin >> R[i], R[i]--; vector>> G(N); vector,ll>> E(M); for(auto &[e, c] : E) { auto &[u, v] = e; cin >> u >> v >> c; u--; v--; G[u].push_back({v, c}); G[v].push_back({u, c}); } vector>> dp(1 << K, vector>(K, {1e18, 1e18})); vector,vector>> dist(K); auto chmin = [&](ll &a, ll b){ if(a > b) a = b; }; rep(i,K) { dist[i].first = dijkstra(G, E[R[i]].first.first ); dist[i].second = dijkstra(G, E[R[i]].first.second); } vector dist0 = dijkstra(G, 0); rep(i,K) { chmin(dp[(1 << i)][i].first , dist0[E[R[i]].first.second] + E[R[i]].second); chmin(dp[(1 << i)][i].second, dist0[E[R[i]].first.first ] + E[R[i]].second); } rep(S,1<