Problem B: Leaves
Problem B: LeavesTime Limit: 1 Sec Memory Limit: 128 MB
Submit: 1173 Solved: 566
Given a tree whose nodes are numbered from 1 to \(n\). You are asked to print all the leaf nodes of the tree in ascending order. The root of the tree is node 1.
The first line contains one integer \(n\) \((1\le n \le 1\ 000\ 000)\), indicating the number of nodes in the tree.
Then \(n-1\) lines follow. Each line contains two integers \(u,v\) \((1 \le u, v \le n)\) describing an edge, indicating the indices of nodes which form an edge.
One line contains integers in ascending order.Multiple integers in one line must be separated by one space.