HDU 1501】的更多相关文章

HDU 1501 Zipper [DFS+剪枝] Problem Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in…
题目链接: HDU - 1501 Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its original order.For examp…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1501 思路:题目要求第三个串由前两个组成,且顺序不能够打乱,搜索大法好 #include<cstdio> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<vector> #include<queue> #incl…
题目大意:个字符串.此题是个非常经典的dfs题. 解题思路:DFS 代码如下:有详细的注释 /* * 1501_2.cpp * * Created on: 2013年8月17日 * Author: Administrator */ #include <iostream> using namespace std; char str1[201], str2[201], str3[401]; int len1, len2, len3; bool flag; bool hash[201][201];…
题意:给定三个串,问c串是否能由a,b串任意组合在一起组成,但注意a,b串任意组合需要保证a,b原串的顺序 例如ab,cd可组成acbd,但不能组成adcb. 分析:对字符串上的dp还是不敏感啊,虽然挺裸的....dp[i][j] 表示a串前i个,b串前j个字母能组成c串前i+j个字母.所以dp[lena-1][lenb-1] = 1; 就行了. 从后往前找就很好找了,从c串最后一个字符开始递归搜索. #include <cstdio> #include <iostream> #i…
Zipper Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4884    Accepted Submission(s): 1742 Problem Description Given three strings, you are to determine whether the third string can be formed…
意甲冠军  是否可以由串来推断a,b字符不改变其相对为了获取字符串的组合c 本题有两种解法  DP或者DFS 考虑DP  令d[i][j]表示是否能有a的前i个字符和b的前j个字符组合得到c的前i+j个字符  值为0或者1  那么有d[i][j]=(d[i-1][j]&&a[i]==c[i+j])||(d[i][j-1]&&b[i]==c[i+j])   a,b的下标都是从1開始的  注意0的初始化 #include<cstdio> #include<cs…
题目大意:输入有一个T,表示有T组测试数据,然后输入三个字符串,问第三个字符串能否由第一个和第二个字符串拼接而来,拼接的规则是第一个和第二个字符串在新的字符串中的前后的相对的顺序不能改变,问第三个字符串能否由前两个得到. 解题报告:这题用dfs,反过来,将第三个字符串按照从前到后的顺序,看能否拆成第一个和第二个字符串,不过这题如果只是这样搜索的话,很明显会超时,所以要减掉其中一些重复的其情况,定义一个二维数组hash[i][j],初始化都为0,然后如果将hash[i][j]标记为1表示第一个字符…
Problem Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its original order. For e…
Zipper Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7813    Accepted Submission(s): 2765 Problem Description Given three strings, you are to determine whether the third string can be formed…