首页 > 其他 > 详细

【UVA】536 Tree Recovery(树型结构基础)

时间:2017-12-03 18:38:15      阅读:221      评论:0      收藏:0      [点我收藏+]

题目

题目
?


?

分析

莫名A了
?


?

代码

#include <bits/stdc++.h>
using namespace std;
string s1,s2;
void build(int l1,int r1,int l2,int r2)
{
    int root=l1,p=l2;
    if(l1>r1) return;
    while(s2[p]!=s1[root] && p<=r2) p++;
    int cnt=p-l2;
    build(l1+1,l1+cnt,l2,p-1);
    build(l1+cnt+1,r1,p+1,r2);
    printf("%c",s1[root]);
}
int main()
{
    while(cin>>s1>>s2)
    {
        build(0,s1.length()-1,0,s2.length()-1);
        puts("");
    }
    return 0;
}

【UVA】536 Tree Recovery(树型结构基础)

原文:http://www.cnblogs.com/noblex/p/7966658.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!