【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

递归题

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = 300; string s1, s2;
int n, idx;
int g[N][2]; int dfs(int l, int r) {
int temp = l;
for (int i = l; i <= r; i++) {
if (s2[i] == s1[idx]) {
temp = i;
}
}
idx++; if (l <= temp - 1) {
g[(int)s2[temp]][0] = dfs(l, temp-1);
} if (temp + 1 <= r) {
g[(int)s2[temp]][1] = dfs(temp + 1, r);
}
return s2[temp];
} void dfs2(int x) {
if (g[x][0]) {
dfs2(g[x][0]);
}
if (g[x][1]) {
dfs2(g[x][1]);
}
cout << (char)x;
} int main() {
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0), cin.tie(0);
while (cin >> s1 >> s2) {
memset(g, 0, sizeof g);
n = s1.size();
idx = 0;
dfs2(dfs(0, n - 1));
cout << endl;
}
return 0;
}

【习题 6-3 UVA - 536】 Tree Recovery的更多相关文章

  1. UVa 536 Tree Recovery | GOJ 1077 Post-order (习题 6-3)

    传送门1: https://uva.onlinejudge.org/external/5/536.pdf 传送门2: http://acm.gdufe.edu.cn/Problem/read/id/1 ...

  2. UVa 536 Tree Recovery(二叉树后序遍历)

    Little Valentine liked playing with binary trees very much. Her favorite game was constructing rando ...

  3. UVa 536 Tree Recovery

    题意:给出一颗二叉树的前序遍历和中序遍历,输出其后序遍历 用杭电1710的代码改一点,就可以了. #include<iostream> #include<cstdio> #in ...

  4. UVA 536 Tree Recovery 建树+不建树

    题意: 给出先序和中序,求后序. 思路: ①建树然后递归输出. //建树的 #include<iostream> #include<cstdio> #include<qu ...

  5. UVA - 536 Tree Recovery (二叉树重建)

    题意:已知先序中序,输出后序. #pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio& ...

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

    题目 题目     分析 莫名A了     代码 #include <bits/stdc++.h> using namespace std; string s1,s2; void buil ...

  7. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  8. UVA 536 (13.08.17)

     Tree Recovery  Little Valentine liked playing with binary trees very much. Her favoritegame was con ...

  9. Tree Recovery(前序中序求后序)

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14640   Accepted: 9091 De ...

  10. poj 2255 Tree Recovery 分治

    Tree Recovery Description Little Valentine liked playing with binary trees very much. Her favorite g ...

随机推荐

  1. 威联通NAS 网站无法登录,可以ssh情况下重启设备方法

    步骤: 1.VPN登录NAS 2.PUTTY SSH登录设备 3.reboot设备 等待重启约5分钟.

  2. 获取个人借阅信息---图书馆client

    在上一篇利用jsoup解析个人信息----图书馆client,获得个人基本信息后.便有了进一步的需求:获取当前借阅的具体信息 获取的方法还是一样的.利用jsoup解析借阅信息页面,获得所需数据,封装成 ...

  3. 你必须要知道的几个CSS技巧

    有些经典的CSS技巧,我们还是需要记住的,这样可以节省我们大量的时间,下面零度就为大家推荐几个比较好的CSS技巧: 1.在不同页面上使用同样的导航代码 许多网页上都有导航菜单,当进入某页时,菜单上相应 ...

  4. Elasticsearch之源码编译

    前期博客 Elasticsearch之下载源码 步骤 (1)首先去git下载源码 https://github.com/elastic/elasticsearch/tree/v2.4.3 下载下来,得 ...

  5. Day1下午解题报告

    预计分数:0+30+30=60 实际分数:0+30+40=70 T1水题(water) 贪心,按长度排序, 对于第一幅牌里面的,在第二个里面,找一个长度小于,高度最接近的牌 进行覆盖. 考场上的我离正 ...

  6. LuoguP2754 [CTSC1999]家园(分层图,最大流)

    题目背景 none! 题目描述 由于人类对自然资源的消耗,人们意识到大约在 2300 年之后,地球就不能再居住了.于是在月球上建立了新的绿地,以便在需要时移民.令人意想不到的是,2177 年冬由于未知 ...

  7. find---查找文件或目录

    ind命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件.并且将查找到的子目录和文件全部进行 ...

  8. iptables-save && iptables-restore iptables规则保存于还原

    iptables-save命令用于将linux内核中的iptables表导出到标准输出设备商,通常,使用shell中I/O重定向功能将其输出保存到指定文件中. 语法 -t:指定要保存的表的名称. 实例 ...

  9. mapper提示Could not autowire. No beans of … type found?

    工具及背景: IntelliJ IDEA 2016.1.3 Ultimate.spring boot, maven项目,利用mybatis 注解的方式查询mysql 在自动生成工具生成代码后,serv ...

  10. POJ——T 3250 Bad Hair Day

    http://poj.org/problem?id=3250 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 19619   ...