Two strings

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 485    Accepted Submission(s): 178

Problem Description
Giving two strings and you should judge if they are matched.
The first string contains lowercase letters and uppercase letters.
The second string contains lowercase letters, uppercase letters, and special symbols: “.” and “*”.
. can match any letter, and * means the front character can appear any times. For example, “a.b” can match “acb” or “abb”, “a*” can match “a”, “aa” and even empty string. ( “*” will not appear in the front of the string, and there will not be two consecutive “*”.
 
Input
The first line contains an integer T implying the number of test cases. (T≤15)
For each test case, there are two lines implying the two strings (The length of the two strings is less than 2500).
 
Output
For each test case, print “yes” if the two strings are matched, otherwise print “no”.
 
Sample Input
3
aa
a*
abb
a.*
abb
aab
 
Sample Output
yes
yes
no
 
Source
 千千详细分析

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
#define PI acos(-1.0)
int t;
char a[],b[];
int dp[][];
int main()
{
scanf("%d",&t);
while(t--){
scanf("%s",a+);
scanf("%s",b+);
memset(dp,,sizeof(dp));
int lena=strlen(a+);
int lenb=strlen(b+);
dp[][]=;
for(int i=;i<=lenb;i++){
if(i==&&b[i]=='*')
dp[i][]=;
for(int j=;j<=lena;j++){
if(b[i]=='.'||b[i]==a[j])
dp[i][j]=dp[i-][j-];
else if(b[i]=='*'){
dp[i][j]=dp[i-][j]|dp[i-][j];
if((dp[i-][j-]||dp[i][j-])&&a[j-]==a[j])
dp[i][j]=;
}
}
}
if(dp[lenb][lena]==)
printf("yes\n");
else
printf("no\n");
}
return ;
}

HDU 6170 dp的更多相关文章

  1. HDU 6170 - Two strings | 2017 ZJUT Multi-University Training 9

    /* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问 ...

  2. hdu 3016 dp+线段树

    Man Down Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  3. HDU 5928 DP 凸包graham

    给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...

  4. 2017多校第9场 HDU 6170 Two strings DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6170 题意:给了2个字符串,其中第2个字符串包含.和*两种特别字符,问第二个字符串能否和第一个匹配. ...

  5. HDU 6170 Two strings (dp)

    /** * 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6170 * 字符串match, '.'代表匹配任意一个字符,"*" 代表 ...

  6. HDU 6170 Two strings( DP+字符串匹配)

    http://acm.hdu.edu.cn/showproblem.php?pid=6170 题目大意: 给出两个字符串s1和s2(长度小于等于2500). s1是一个正常的包含大小写字母的字符串,s ...

  7. hdu 6170 Two strings dp

    Two strings Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Prob ...

  8. 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 ...

  9. HDU 1069 dp最长递增子序列

    B - Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

随机推荐

  1. Mybatis初步详细配置

    1.Mybatis所需包 下载地址:https://github.com/mybatis/mybatis-3/releases,其中log4j是日志包,mysql是数据库所需包,需自行下载 2.项目结 ...

  2. CS190.1x-ML_lab1_review_student

    这是CS190.1x第一次作业,主要教你如何使用numpy.numpy可以说是python科学计算的基础包了,用途非常广泛.相关ipynb文件见我github. 这次作业主要分成5个部分,分别是:数学 ...

  3. effective c++ 笔记 (9-12)

    //---------------------------15/03/29---------------------------- //#9    绝不在构造和析构过程中调头virtual函数 { / ...

  4. Sqlserver_分组

    create table orders ( id int, orderName varchar() ) go create table cars ( id ,) , ordersid int, pna ...

  5. VirtualBox虚拟机怎么导入已经存在的vdi文件

    VirtualBox虚拟机怎么导入已经存在的vdi文件 第一章 1.原因 早上一不小心将virtualBox 卸载了,(不知道怎么了, 里面得虚拟机全部都没有了,但是vdi文件还在) 2.解决办法 直 ...

  6. 阿里云ESC入网和出网指的什么

    什么是入网带宽和出网带宽 云服务器 ECS 的入网带宽和出网带宽皆以服务器角度出发.下表给出了入网带宽和出网带宽的具体内容: 带宽类别 (Mbit/s) 描述 入网带宽 流入云服务器 ECS 的带宽从 ...

  7. Github相册博客搭建

    前一段时间我看见一个问答,大概意思就是程序员都是怎么用自己的专业技能逗女朋友或表白的. 看了很多,有写定时关机脚本恶搞的,也有简单写个html展示的,其中最著名的就是几年前有个人写了个网页记录他们在一 ...

  8. shell实现压缩多个文件

    Linux环境下写一个脚本 从键盘让用户输入几个文件,脚本能够将此几个文件归档压缩成一个文件: 1.首先介绍一下case语句格式 case SWITCH in value1) statement .. ...

  9. pip virtualenv requirement

    原文:https://blog.csdn.net/u011860731/article/details/46561513 pip可以很方便的安装.卸载和管理Python的包.virtualenv则可以 ...

  10. Win10 + vs2017 编译并配置tesseract4.1.0

    tesseract 是一个开源的OCR (Optical Character Recognition , 光学字符识别) 引擎,本文就介绍一下自己在编译 tesseract4.1.0时遇到的一些坑,希 ...