Tree Cutting | 프로그래밍의 벗 PivotOJ
PivotOJ

Tree Cutting

시간 제한: 3000ms메모리 제한: 1024MB출처: NOI 2022 QualificationBOJ 27286

문제

A country has NN cities numbered from 11 to NN and N1N - 1 bidirectional highways. It is possible to travel from any city to any other city using only the highways.

The distance between two cities xx and yy is defined as the number of highways required to travel from xx to yy.

The governor has decided to demolish a highway and build another highway such that the largest distance between any two cities is maximized.

Find this maximum largest distance.

입력

Your Program must read from standard input.

The first line contains an integer, NN, the number of cities.

In the next N1N - 1 lines, each line contains 22 distinct integers uu and vv, representing a highway connecting cities uu and vv.

출력

Your program must print to standard output.

The output should contain a single integer on a single line, the new largest distance between any two cities.

예제

예제 1

입력
4
1 2
1 3
3 4
출력
3

예제 2

입력
6
1 2
2 3
2 5
4 5
5 6
출력
5
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.