[BOJ] 1967 : 트리의 지름 [그래프/트리](Python)


[BOJ] 1967 : 트리의 지름 [그래프/트리](Python)

문제 링크 https://www.acmicpc.net/problem/1967 1967번: 트리의 지름 파일의 첫 번째 줄은 노드의 개수 n(1 ≤ n ≤ 10,000)이다. 둘째 줄부터 n-1개의 줄에 각 간선에 대한 정보가 들어온다. 간선에 대한 정보는 세 개의 정수로 이루어져 있다. 첫 번째 정수는 간선이 연 www.acmicpc.net 소스 코드 import sys sys.setrecursionlimit(10**6) def main(): n = int(input()) visited = [False] * (n+1) distance = [0] * (n+1) graph = [[] for _ in range(n+1)] for _ in range(n-1): parent, child, weight = map(..


원문링크 : [BOJ] 1967 : 트리의 지름 [그래프/트리](Python)