#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x V; int mat[40][40]; int ok[40]; int OPT[(1 << 15)][40]; int minimum_steiner_tree() { const int n = N; const int numT = V.size(); if (numT <= 1) return 0; for (int S = 0; S < (1 << numT); ++S) for (int x = 0; x < n; ++x) OPT[S][x] = 100000; for (int p = 0; p < numT; ++p) // trivial case for (int q = 0; q < n; ++q) OPT[1 << p][q] = mat[V[p]][q]; for (int S = 1; S < (1 << numT); ++S) { // DP step if (!(S & (S-1))) continue; for (int p = 0; p < n; ++p) for (int E = 0; E < S; ++E) if ((E | S) == S) OPT[S][p] = min( OPT[S][p], OPT[E][p] + OPT[S-E][p] ); for (int p = 0; p < n; ++p) for (int q = 0; q < n; ++q) OPT[S][p] = min( OPT[S][p], OPT[S][q] + mat[p][q] ); } int ans = 100000; for (int S = 0; S < (1 << numT); ++S) for (int q = 0; q < n; ++q) ans = min(ans, OPT[S][q] + OPT[((1 << numT)-1)-S][q]); return ans; } int dodo(ll mask) { UF uf; priority_queue > Q; int x,y; FOR(x,N) FOR(y,x) if(x!=y && (mask&(1LL< p=Q.top(); Q.pop(); x=p.second/100, y=p.second%100; if(uf[x]!=uf[y]) { tot+=-p.first; uf.unite(x,y); } } return tot; } void solve() { int i,j,k,l,r,x,y; string s; UF uf; FOR(x,40) FOR(y,40) mat[x][y]=100000000; FOR(x,40) mat[x][x]=0; cin>>N>>M>>T; FOR(i,M) { cin>>A[i]>>B[i]>>C[i]; mat[A[i]-1][B[i]-1]=mat[B[i]-1][A[i]-1]=C[i]; } FOR(i,N) FOR(x,N) FOR(y,N) mat[x][y]=min(mat[x][y],mat[x][i]+mat[i][y]); FOR(i,T) cin>>x, V.push_back(x-1), ok[V[i]]=1; if(T<=12) { cout< V2; FOR(i,N) if(ok[i]==0) V2.push_back(i); int mi=10000000; ll mask=0; FOR(i,N) if(ok[i]) mask|=1LL<