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

【题意】

在这里输入题意

【题解】

递归题

【代码】

#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. 学习《TensorFlow实战Google深度学习框架 (第2版) 》中文PDF和代码

    TensorFlow是谷歌2015年开源的主流深度学习框架,目前已得到广泛应用.<TensorFlow:实战Google深度学习框架(第2版)>为TensorFlow入门参考书,帮助快速. ...

  2. Fedora 29 Linux发行版发布,新功能使Web开发人员的工作更方便

    Matthew Miller宣布发布Fedora 29.这个项目的最新版本是在Fedora Core 1发布后几乎整整15年才发布的,并且可以在多个版本中用于多个体系结构. 最新版本的Fedora已经 ...

  3. oracle基础入门(一)

    一:Oracle的安装     我所知的Oracle的数据库有 10g,11g, 12g, 我们常用的是10g ,因为10g有scott的用户,而11和12现在还没有(哪位大神看到有问题可以指出哦), ...

  4. ecshop微信通中微信自动登录的设置方法

    ecshop微信通中微信自动登录的设置方法 来 源:共享世纪 作 者:网络 时间:2015-12-03 点击: 4017 注意:微信自动登录,必须同时满足两个条件: 第一.微信公众号必须是服务号经过认 ...

  5. jquery autocomplete文本自己主动补全

    文本自己主动补全功能确实非常有用. 先看下简单的效果:(样式不咋会写) 以下介绍几种: 1:jqery-actocomplete.js 这个网上有个写好的实例,上面挺具体的,能够下来执行下就清楚了就不 ...

  6. layer:web弹出层解决方案

    layer:web弹出层解决方案 一.总结 一句话总结:http://layer.layui.com/ 1.layer中弹出层tips的使用(代码)是怎样的? 使用还是比较简单方便的 //tips层- ...

  7. ElasticSearch 架构图

    ElasticSearch 架构图 从下往上来分析ElasticSearch 架构图 Gateway代表ElasticSearch索引的持久化存储方式. 在Gateway中,ElasticSearch ...

  8. OpenCV —— 图像局部与部分分割(一)

    背景减除 一旦背景模型建立,将背景模型和当前的图像进行比较,然后减去这些已知的背景信息,则剩下的目标物大致就是所求的前景目标了 缺点 —— 该方法基于一个不长成立的假设:所有像素点是独立的 场景建模 ...

  9. mac: brew的删除

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" ...

  10. lastlog---显示系统中所有用户最近一次登录信息。

    lastlog命令用于显示系统中所有用户最近一次登录信息. lastlog文件在每次有用户登录时被查询.可以使用lastlog命令检查某特定用户上次登录的时间,并格式化输出上次登录日志/var/log ...