/**
* 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6170
* 字符串match, ‘.’代表匹配任意一个字符,“*” 代表前面的那个字符可以重复
* 出现0到无穷次。
*
* 思路: dp[i][j];代表前i个字符与另一个前j个字符是否能匹配? true:false;
* 假设i是B串,j是A串
* 如果是:不是*,那就直接判断相等或者其中一个是否为点。是进行转移 dp[i][j]=dp[i-1][j-1];
* 如果是*,我们需要从dp[i-1][j] dp[i-2] 转过来,
* 如果 A串的当前字符与之前一样,那么还可以从 dp[i-1][j-1],dp[i][j-1]转过来。
*/ #include <bits/stdc++.h>
using namespace std;
const int maxn = 2600; char a[maxn], b[maxn];
bool dp[maxn][maxn];
int lena, lenb;
int main()
{
int T;
scanf("%d%*c", &T);
while (T--)
{
memset(dp, 0, sizeof(dp));
a[0] = b[0] = 1;
scanf("%s%s",a+1,b+1);
lena = strlen(a+1);
lenb = strlen(b+1);
dp[0][0] = true;
for (int i = 1; i <= lenb; i++)
{
for (int j = 0; j <= lena; j++)
{
if (b[i] == '.' || a[j] == b[i])
dp[i][j] |= dp[i - 1][j - 1];
else if (b[i] == '*')
{
dp[i][j] |= dp[i - 2][j];
dp[i][j]|=dp[i - 1][j];
if (a[j - 1] == a[j])
{
dp[i][j]|=dp[i-1][j-1];
dp[i][j]|=dp[i][j-1];
}
}
}
}
puts(dp[lenb][lena] ? "yes" : "no");
}
return 0;
}

HDU 6170 Two strings (dp)的更多相关文章

  1. 2017ACM暑期多校联合训练 - Team 9 1010 HDU 6170 Two strings (dp)

    题目链接 Problem Description Giving two strings and you should judge if they are matched. The first stri ...

  2. HDU 5791:Two(DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=5791 Two Problem Description   Alice gets two sequences A ...

  3. HDU 4833 Best Financing(DP)(2014年百度之星程序设计大赛 - 初赛(第二轮))

    Problem Description 小A想通过合理投资银行理财产品达到收益最大化.已知小A在未来一段时间中的收入情况,描述为两个长度为n的整数数组dates和earnings,表示在第dates[ ...

  4. HDU 6170----Two strings(DP)

    题目链接 Problem Description Giving two strings and you should judge if they are matched.The first strin ...

  5. hdu 4055 Number String(dp)

    Problem Description The signature of a permutation is a string that is computed as follows: for each ...

  6. HDU 4833 Best Financing (DP)

    Best Financing Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. HDU 1422 重温世界杯(DP)

    点我看题目 题意 : 中文题不详述. 思路 : 根据题目描述及样例可以看出来,如果你第一个城市选的是生活费减花费大于等于0的时候才可以,最好是多余的,这样接下来的就算是花超了(一定限度内的花超),也可 ...

  8. HDU 1176 免费馅饼(DP)

    点我看题目 题意 : 中文题.在直线上接馅饼,能接的最多是多少. 思路 :这个题其实以前做过.....你将这个接馅饼看成一个矩阵,也不能说是一个矩阵,反正就是一个行列俱全的形状,然后秒当行,坐标当列, ...

  9. Codeforces 543C Remembering Strings(DP)

    题意比较麻烦 见题目链接 Solution: 非常值得注意的一点是题目给出的范围只有20,而众所周知字母表里有26个字母.于是显然对一个字母进行变换后是不影响到其它字符串的. 20的范围恰好又是常见状 ...

随机推荐

  1. How do you stop Ansible from creating .retry files in the home directory?

    There are two options that you can add to the [defaults] section of the ansible.cfg file that will c ...

  2. 制作个人开发IDE

     1.打开VS2013,新建项目: 2.点击下一步,下一步.到达例如以下界面: 3.下一步 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R ...

  3. Battery Charging Specification 1.2 中文详解

    转:       http://blog.csdn.net/liglei/article/details/228 1. Introduction 1.1 Scope 规范定义了设备通过USB端口充电的 ...

  4. CentOS中文乱码的问题

    修改CentOS 6.4 root用户的系统默认语言设置 最近用Virtual Box 虚拟了一个CentOS系统,版本6.4,安装时使用简体中文.发现用普通用户登录的时候 设置语言环境为Englis ...

  5. windows下rsync部署安装

    windows下rsync部署安装 2012-06-05 12:06:13|  分类: 系统 |  标签:rsync  windows   |字号 订阅   rsync在windows与windows ...

  6. Anaconda2

    Anaconda 是一个打包的python,一次把好多需要的包都安装好了.对于Python2.7把PyQt5都弄好了,不需要自己来编译! 看看这个 http://conda.pydata.org/do ...

  7. 多媒体开发之sps---解析sps得到图像的宽高

    (1)通过块的宽高解析出真个h264的分辨率 如何解析SDP中包含的H.264的SPS和PPS串 http://www.pernet.tv.sixxs.org/thread-109-1-1.html ...

  8. 嵌入式驱动开发之---Linux ALSA音频驱动(一)

    本文的部分内容参考来自DroidPhone的博客(http://blog.csdn.net/droidphone/article/details/6271122),关于ALSA写得很不错的文章,只是少 ...

  9. Android:实现两个Activity相互切换而都不走onCreate()

    本文要实现的目的是: 有3个Activity: A,B,C.从A中能够进入B,B中能够进入C.而且B和C之间可能须要多次相互切换,因此不能使用普通的startActivity-finish方式,由于又 ...

  10. Java&amp;Xml教程(十)XML作为属性文件使用

    我们一般会将Java应用的配置參数保存在属性文件里.Java应用的属性文件能够是一个正常的基于key-value对,以properties为扩展名的文件.也能够是XML文件. 在本案例中.將会向大家介 ...