Codeforces Round 1064 (Div. 1)
E
Rainbow Branch
Codeforces
3200
原题
← DF →
翻译中…

Given a tree with $n$ vertices, you need to assign a color to each edge. Define the inconvenience of an assignment as the maximum number of colors on the path between any two vertices.

翻译中…

You need to assign exactly $k$ different colors (each color must appear at least once) to the edges while minimizing the inconvenience of the assignment.

翻译中…

Please calculate the minimum inconvenience for all $k=1,2,\ldots,n-1$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of the input contains one positive integer $n$ ($3\le n\le3\cdot10^5$) — the number of vertices.

翻译中…

The next $n-1$ lines each contain two positive integers $u_i,v_i$ ($1\le u_i,v_i\le n$) — indicating that there is an edge between vertices $u_i$ and $v_i$.

翻译中…

It is guaranteed that the edges in the input form a tree.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $3\cdot10^5$.

翻译中…

Output

翻译中…

For each test case, print a single line containing $n-1$ integers. The $i$-th integer represents the minimum inconvenience for $k=i$.

翻译中…

Note

翻译中…

In the first test case, possible solutions for $k=1,2,\ldots,n-1$ are as follows:

翻译中…

image

翻译中…

样例

Input #1
3
6
3 4
6 1
3 2
3 1
4 5
8
8 6
7 4
8 5
2 7
3 2
5 2
1 2
3
1 2
2 3
Output #1
1 2 2 3 4
1 2 2 2 3 4 5
1 2
InputCopy OutputCopy
题目信息
题号
2165E
时间限制
3 s
内存限制
1024 MB
标签
构造
动态规划
贪心
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。