Given a rooted tree with $N$ vertices. The root of tree is the vertex $0$ . A parent of the vertex $i$ is $p _ i$ . You will get $N$ rooted subtrees by choosing a root. Classify them by isomorphism of rooted trees.
Now print a number of distinct subtrees $K$ and an integer seqence $a _ 0 , a _ 1 , \ldots , a _ {N-1}$ that satisfy the following conditions.
$N$
$p _ 1$ $p _ 2$ $\ldots$ $p _ {N-1}$
$K$
$a _ 0$ $a _ 1$ $\ldots$ $a _ {N-1}$
If there are multiple solutions, print any of them.
11 0 1 1 2 2 0 6 6 8 8
4 3 2 1 0 0 0 2 0 1 0 0
5 0 1 2 3
5 4 3 2 1 0
No. | Testdata Range | Score |
---|