====== 네트워크 연결 ====== ===== 풀이 ===== * 그냥 [[ps:최소 신장 트리]]를 구하기만 하면 되는 문제. 특별히 언급할 내용이 없다. ===== 코드 ===== """Solution code for "BOJ 1922. 네트워크 연결". - Problem link: https://www.acmicpc.net/problem/1922 - Solution link: http://www.teferi.net/ps/problems/boj/1922 Tags: [Minimum spanning tree] """ import sys from teflib import graph as tgraph def main(): N = int(sys.stdin.readline()) M = int(sys.stdin.readline()) edges = [] for _ in range(M): a, b, c = [int(x) for x in sys.stdin.readline().split()] edges.append((a - 1, b - 1, c)) mst_edges = tgraph.minimum_spanning_tree(edges, N) print(sum(c for a, b, c in mst_edges)) if __name__ == '__main__': main() * Dependency: [[:ps:teflib:graph#minimum_spanning_tree|teflib.graph.minimum_spanning_tree]] {{tag>BOJ ps:problems:boj:골드_4}}