시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 128 MB | 1 | 1 | 1 | 100.000% |
JAG is the new revolutionary game of the company $BEST$. In this game players play $T$ rounds and in each round they have a map of $N$ territories. Exactly $N-1$ pairs of these territories have common border. This map is connected, that is, for every two territories $u$ and $v$, you can walk from $u$ to $v$, possibly by crossing some other territories. Players are choosing territories in turns, until all territories are chosen. There are two rules:
We define distance between two territories $u$ and $v$ as the smallest possible number of borders, that you have to cross on some path from $u$ to $v$. First player's goal is to minimize the distance between two furthest territories chosen by him. Second player's goal is to maximize that distance. Print the distance between two furthest territories chosen by the first player, if both players play in the optimal way.
In the first line of input is the number of rounds $T$. Description of $T$ rounds follows.
For each round, in the first line, there is the number $N$ ($3 \leq N \leq 10^5$), representing the number of territories. In the following $N-1$ lines there are two numbers $u$ and $v$, representing pair of territories having common border. It is guaranteed that you can walk from any territory to any other territory by crossing some borders.
It is guaranteed that the sum of $N$ over all of the rounds doesn't exceed $200000$.
Print $T$ lines, in $i$th of them the distance between two furthest territories of the first player, if both players play in the optimal way.
1 5 1 2 1 3 1 4 1 5
2