| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 1024 MB | 111 | 18 | 16 | 28.571% |
You are given a tree with $N$ vertices. You can repeat the following operation at most 10ドル^5$ times.
Your task is transform the given tree so that its diameter is at most 3ドル$. Find a sequence of operations that does so.
The first line contains one integer $N$.
The $i$-th of the following $N-1$ lines contains space-separated two integers $x_i$ and $y_i,ドル meaning that the $i$-th edge connects vertices $x_i$ and $y_i$ in the tree.
At the first line, print $K,ドル the number of operations.
In the next $K$ line, print four integers $v_1,ドル $v_2,ドル $v_3,ドル $v_4$ separated by space.
If there are multiple solutions, print any. It can be proven that there exists at least one way to achieve the goal.
Note that you do not have to minimize $K$.
6 1 2 2 3 3 4 4 5 5 6
3 4 3 2 1 6 5 4 1 2 4 6 1
The distance between two vertices $u$ and $v$ is defined as the number of the edges of the unique path from $u$ to $v$.
The diameter of a tree is the maximum distance between any two vertices.