日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

hdu-5707-Combine String

發布時間:2025/3/15 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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\n");elseprintf("No\n");}elseprintf("No\n");} }

?

轉載于:https://www.cnblogs.com/nr1999/p/8997251.html

總結

以上是生活随笔為你收集整理的hdu-5707-Combine String的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。