poj 2192 Zipper (DP)
2014-12-20 13:40
281 查看
#include <iostream> #include <cstdio> #include <climits> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <algorithm> #include <time.h> #define LL long long int dp[1001][1001]; char str1[1001],str2[1001],str3[1001]; int main() { //freopen("G://test.txt","r",stdin); int t,n,m,len1,len2; scanf("%d",&t); for(int i=0;i<t;++i){ scanf("%s%s%s",str1,str2,str3); memset(dp,0,sizeof(dp)); int cur=1; len1=strlen(str1); len2=strlen(str2); int pos=1; dp[0][0]=1; if(str1[0]==str3[0]) dp[1][0]=1; if(str2[0]==str3[0]) dp[0][1]=1; for(int j=0;j<=len1;j++){ for(int k=0;k<=len2;++k){ if(j>=1&&str1[j-1]==str3[j+k-1]){ dp[j][k]=dp[j-1][k]||dp[j][k]; } if(k>=1&&str2[k-1]==str3[j+k-1]){ dp[j][k]=dp[j][k-1]||dp[j][k]; } } } printf("Data set %d: ",i+1); if(dp[len1][len2]==1) printf("yes\n"); else printf("no\n"); } return 0; }
相关文章推荐
- POJ 2192 Zipper (dp)
- [简单DP] POJ 2192 Zipper
- POJ 2192 Zipper(判断第3个字符串能否有前两个字符串组成) 水dp
- POJ 2192 Zipper (简单DP)
- POJ 2192 Zipper (DFS / DP)
- POJ 2192 Zipper [dfs+剪枝 || dp]
- HDU-1501 (POJ-2192) Zipper (DFS||DP)
- POJ 2192 / ZOJ 2401 : Zipper - DP
- (DP)POJ2192—Zipper
- POJ 2192 Zipper简单dp
- POJ - 2192 - Zipper (简单DP)
- POJ-2192 Zipper-DP-字符串
- POJ 2192 (DP)
- poj 2192 dp
- POJ-2192 Zipper-顺序合成串匹配
- POJ 2192 【DP】
- Poj 2192 Zipper
- poj 2192 Zipper(DFS+剪枝)
- poj_2192Zipper
- POJ 2192 Zipper