zoukankan      html  css  js  c++  java
  • POJ 2255 Tree Recovery 树的遍历,分治 难度:0

    http://poj.org/problem?id=2255

    #include<cstdio>
    #include <cstring>
    using namespace std;
    const int maxn = 27;
    char pre[maxn],in[maxn];
    char past[maxn];
    void tre(int ps,int pe,int is,int ie,int& ind)
    {
        int lnum = strchr(in,pre[ps]) - in - is;
    
        if(lnum != 0)
        {
            tre(ps + 1,ps + 1 + lnum,is ,is + lnum,ind);
        }
        if(is + lnum + 1 != ie)
        {
            tre(ps + 1 + lnum,pe,is + lnum + 1 ,ie,ind);
        }
        past[ind++] = pre[ps];
    }
    int main()
    {
        while(scanf("%s%s",pre,in) == 2)
        {
            int ind = 0;
            int len = strlen(pre);
            tre(0,len,0,len,ind);
            past[len] = 0;
            printf("%s
    ",past);
        }
        return 0;
    }
    
  • 相关阅读:
    Burp suite
    CTF 压缩包分析
    PHP代码审计
    SQL注入
    常考文件包含漏洞
    PHP黑魔法
    CTF WEB笔记
    MsSQL数据库提权
    ATT&CK实战系列
    Linux访问控制
  • 原文地址:https://www.cnblogs.com/xuesu/p/4668980.html
Copyright © 2011-2022 走看看