목차

차원의 나무 여행

ps
링크acmicpc.net/…
출처BOJ
문제 번호32755
문제명차원의 나무 여행
레벨골드 4
분류

트리

시간복잡도O(n)
인풋사이즈n<=500
사용한 언어Python 3.13
제출기록32412KB / 32ms
최고기록32ms
해결날짜2025/10/22

풀이

코드

"""Solution code for "BOJ 32755. 차원의 나무 여행".

- Problem link: https://www.acmicpc.net/problem/32755
- Solution link: http://www.teferi.net/ps/problems/boj/32755

Tags: [tree]
"""

from teflib import tree as ttree


def main():
    N, tree = ttree.create_tree_from_input()
    is_star_graph = max(len(neighbors) for neighbors in tree) == N - 1
    print(N - 1 if is_star_graph else N)


if __name__ == '__main__':
    main()