import std.algorithm, std.conv, std.range, std.stdio, std.string; alias Graph!(int, size_t) graph; void main() { auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1], t = rd1[2]; auto e = new Edge[](m); foreach (i; 0..m) { auto rd2 = readln.splitter; auto src = rd2.front.to!size_t-1; rd2.popFront(); auto dst = rd2.front.to!size_t-1; rd2.popFront(); e[i] = Edge(src, dst, rd2.front.to!int); } auto v = t.iota.map!(_ => readln.chomp.to!size_t-1).array; v.sort(); auto calc1() { auto g = new int[][](n, n); foreach (ref r; g) r[] = graph.inf; foreach (i; 0..n) g[i][i] = 0; foreach (ref ei; e) g[ei.s][ei.t] = g[ei.t][ei.s] = ei.w; auto r = graph.minimumSteinerTree(v, g); return r >= graph.inf ? 0 : r; } auto calc2() { auto cb = ulong(0); foreach (vi; v) cb = cb.bitSet(vi); auto w = n.iota.setDifference(v).array; e.sort!"a.w < b.w"; auto u = n - t, ans = int.max; foreach (i; 0..1< i.dup).array; foreach (k; 0..n) foreach (i; 0..n) foreach (j; 0..n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); auto opt = new Wt[][](1< !l.empty); } }