2591 -
The Tree Movers North America - North Central - 2002/2003 | |||||
Submit | Ranking |
Given two binary search trees, A and B, with nodes identified by (that is,
having keys equal to) positive, non-zero integers, and the use of commands
``delete K Recall that in a binary search tree, the keys of all nodes in the left
subtree of a node with key K
The ``delete K Since we seek to transform tree A into tree B, it follows that commands will
be applied only to tree A; tree B is ``read only".
It is easy to see that it should never require more than N + 1
There will be multiple input cases. For each case, the input contains the
description of tree A followed by the description of tree B. Each tree
description consists of an integer N
For each case, display a single line containing the input case number (1, 2,...)
Input
Output
Sample
Input
4 5 2 7 4 6 5 3 7 1 4 9
0 0
1 100 0
0 1 100
3 100 49 37 2 200 152
-1
Sample
Output
Case 1: 5 commands.
Case 2: 0 commands.
Case 3: 1 command.
Case 4: 1 command.
Case 5: 3 commands.
North Central 2002-2003