====== 섬 연결하기 ====== * 아무 트릭도 없이 순수한 [[[ps:최소 신장 트리]] 문제. ===== 코드 ===== """Solution code for "Programmers 42861. 섬 연결하기". - Problem link: https://programmers.co.kr/learn/courses/30/lessons/42861 - Solution link: http://www.teferi.net/ps/problems/programmers/42861 """ from teflib import tgraph def solution(n, costs): wgraph = [{} for _ in range(n)] for u, v, w in costs: wgraph[u][v] = wgraph[v][u] = w return tgraph.minimum_spanning_tree(wgraph) * Dependency: [[:ps:teflib:tgraph#minimum_spanning_tree|teflib.tgraph.minimum_spanning_tree]] {{tag>프로그래머스 ps:problems:programmers:Level_3 tag:teflib:minimum_spanning_tree}}