Description
给定前中序得到后序序列。
Input
第一行包含一个n(1<=n<=1000)表示有n个节点,后两行为前序和后序序列。
Output
输出后序序列。
Sample Input
9
1 2 4 7 3 5 8 9 6
4 7 2 1 8 5 9 3 6
Sample Output
7 4 2 8 9 5 6 3 1
Solution
由前中、后中得到其他序列的板题。
#include <iostream>
#include <cstdio>
#include <vector>
#define N 1005
using namespace std;
vector<int> V; //存放父节点
int pre[N], in[N]; //先序数组和后序数组
void make(int preleft, int preright, int inleft, int inright