Tree Cutting

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

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.

제한

  • 3N300,0003 ≤ N ≤ 300\\,000
  • 1u,vN1 ≤ u, v ≤ N