← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)

	// cnt[i] stores the number of special vertices in the component rooted at i
	cnt := make([]int, n+1)
	for i := 0; i < k; i++ {
		var x int
		fmt.Fscan(in, &x)
		cnt[x] = 1
	}

	type edge struct {
		u, v, w int
	}
	edges := make([]edge, m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &edges[i].u, &edges[i].v, &edges[i].w)
	}

	// Sort edges by weight to process for MST / Minimax path
	sort.Slice(edges, func(i, j int) bool {
		return edges[i].w < edges[j].w
	})

	parent := make([]int, n+1)
	for i := 1; i <= n; i++ {
		parent[i] = i
	}

	var find func(int) int
	find = func(i int) int {
		if parent[i] != i {
			parent[i] = find(parent[i])
		}
		return parent[i]
	}

	ans := 0
	for _, e := range edges {
		u := find(e.u)
		v := find(e.v)
		if u != v {
			// If we are merging two components that both contain special vertices,
			// the weight of this edge determines the bottleneck for paths between them.
			// Since we process edges in increasing order, this will eventually
			// be the maximum weight needed to connect all special vertices.
			if cnt[u] > 0 && cnt[v] > 0 {
				ans = e.w
			}
			parent[u] = v
			cnt[v] += cnt[u]
		}
	}

	// The answer is the same for all special vertices
	for i := 0; i < k; i++ {
		if i > 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, ans)
	}
	fmt.Fprintln(out)
}
```