zoukankan      html  css  js  c++  java
  • hdu-5707-Combine String

    题意:给你三个字符串,让你计算1 2 串和3 串是否匹配,就是3串可以分解为 1  2 串,字母顺序必须是按照1 2 串的字母前后顺序。

    DP代码太深奥 看不太透,这个代码比较好理解一点:

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<time.h>
    #include<iostream>
    #include<ctype.h>
    #include<map>
    #include<set>
    #include<string>
    #include<vector>
    #include<algorithm>
    #include<stdlib.h>
    #include<queue>
    #include<stack>
    using namespace std;
    map<char,int>ma,mc;
    int main()
    {
        int i,j,k;
        string a,b,c;
        while(cin>>a>>b>>c)
        {
            ma.clear();
            mc.clear();
            int lea=a.size();
            int leb=b.size();
            int lec=c.size();
            for(i=0;i<lea;i++)
                ma[a[i]]++;
            for(i=0;i<leb;i++)
                ma[b[i]]++;
                int x=0;
                int y=0;
            for(i=0;i<lec;i++)
            {
                mc[c[i]]++;
                if(x<lea&&c[i]==a[x])
                    x++;
                if(y<leb&&c[i]==b[y])
                    y++;
    
            }
            int fl=1;
            map<char,int>::iterator tt;
            for(tt=mc.begin();tt!=mc.end();tt++)
            {
                if(mc[tt->first]!=ma[tt->first])
                {
                    fl=0;
                    break;
                }
            }
            if(fl)
            {
                if(x==lea&&y==leb)
                    printf("Yes
    ");
                else
                    printf("No
    ");
            }
            else
                printf("No
    ");
        }
    }
  • 相关阅读:
    Scala Ant Tasks
    Git挂钩
    读写文件
    DC10用CSS定位控制网页布局
    table设置colspan属性,列宽显示错位解决方法
    ATM和购物商城-错题集
    python 函数参数多种传递方法
    python 函数 初学
    python 集合 gather
    元组 字体高亮 购物车练习
  • 原文地址:https://www.cnblogs.com/nr1999/p/8997251.html
Copyright © 2011-2022 走看看