| acmsguru |
|---|
| Закончено |
. All nodes are numbered from 1 to n. Node number 1 is always the root of the tree. Each of the other nodes has a unique parent in the tree. Each of the next n - 1 lines of the input file contains one integer — the number of the parent node for nodes 2, 3,..., n respectively. Each of the last m lines of the input file contains one integer ranging from
to
— the value of the corresponding leaf. Leaves of the tree have numbers from n - m + 1 to n. sample input | sample output |
5 4 1 1 1 1 1 4 7 9 | 2 |
sample input | sample output |
5 4 1 1 1 1 1 4 7 10 | 3 |
sample input | sample output |
7 4 1 2 1 2 3 3 2 10 7 15 | 3 3 8 |
sample input | sample output |
2 1 1 100 | 2147483647 |
| Название |
|---|


