PKU 2255 Tree Recovery(二叉树)
来源:互联网 发布:积分管理数据库设计 编辑:程序博客网 时间:2024/05/29 06:44
前中求后
rt需在pre里面找
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <map>#include <queue>#include <string>#include <set>#include <vector>using namespace std;const int N=27,INF=0x3f3f3f3f;char in[N],pre[N];int n,k;void dfs(int l,int r,int rt){ int i; for(i=l;in[i]!=pre[rt];i++); if(l<=i-1) dfs(l,i-1,rt+1);//l,i->in[] rt->pre[] if(i+1<=r) dfs(i+1,r,rt+i-l+1); k==0?printf("%c",in[i]):printf(" %c",in[i]);}int main(){ while(~scanf("%s %s",pre,in)) { k=0; dfs(0,strlen(pre)-1,0); puts(""); }}
0 0
- PKU 2255 Tree Recovery(二叉树)
- 二叉树(Tree Recovery)
- POJ 2255 Tree Recovery 二叉树遍历
- POJ 2255 Tree Recovery [二叉树]
- Poj 2255-Tree Recovery//二叉树,递归
- POJ 2255 Tree Recovery ( 二叉树)
- POJ 2255 Tree Recovery 二叉树基础
- POJ 2255 Tree Recovery 二叉树恢复
- POJ 2255 Tree Recovery(二叉树)
- POJ 2255 Tree Recovery(二叉树重建)
- POJ 2255 Tree Recovery (二叉树遍历)
- poj 2255 Tree Recovery(二叉树)
- 【POJ 2255 Tree Recovery】+ 二叉树
- POJ 2255 Tree Recovery 二叉树
- POJ 2255 Tree Recovery 二叉树的遍历
- POJ 2255 Tree Recovery 二叉树+遍历+递归
- poj 2255 Tree Recovery(求后序遍历,二叉树)
- poj 2255 Tree Recovery(二叉树的遍历)
- git 冲突解决
- 乐观锁与悲观锁——解决并发问题
- CALayer画多边形柱体
- performDraw
- 解决libc.so.6: version `GLIBC_2.14′ not found问题
- PKU 2255 Tree Recovery(二叉树)
- 天梯赛练习——帅到没朋友
- Rxjava 从入门到开发
- ORA-12560: TNS: 协议适配器错误
- Yii2.0 ArrayHelper::map() 使用方法
- FFmpeg发送流媒体的命令(UDP,RTP,RTMP)
- 剑指offer:树的子结构
- ajax中error函数参数详解
- pthread_create()创建线程最大个数