Problem1269--还原二叉树II

1269: 还原二叉树II

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 587  Solved: 397
[Submit] [Status] [Web Board] [Creator:]

Description

PIPI现在有两个序列,分别为二叉树的中序序列和二叉树的后序序列,他想由这两个序列还原二叉树,你能帮PIPI还原吗?

Input

第一行输入序列的长度n (0<n<100).
第二行输入二叉树的中序序列。
第三行输入二叉树的后序序列。

Output

输出二叉树的先序遍历序列。

Sample Input

3
2 1 3
2 3 1

Sample Output

1 2 3

Source/Category