http://acm.hdu.edu.cn/showproblem.php?pid=6170

. 匹配任意字符,x* 匹配任意长度的 x (x 为任意字符,长度可以为 0 )

正则表达式

#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <regex>
#include <sys/types.h> const int MAX_N = 3e3 + 7; char s1[MAX_N], s2[MAX_N],sr[MAX_N * 1000];
inline bool solve() {
gets(s1); gets(s2);
std::regex rx("\\.\\*");
char fmt[] = "(.)\\1*";
*std::regex_replace(sr, s2, s2 + strlen(s2), rx, fmt) = '\0';
return regex_match(s1,std::regex(sr));
return false;
} int main() {
int T; scanf("%d", &T); getchar();
while(T--) puts(solve() ? "yes" : "no");
return 0;
}
  • 需要 sys/types.h , regex
  • regex_replace(s,first,last,rgx,tmt,flags) 目标地址,源首,源末,替换目标,替换内容,
  • regex_match(s,rgx) 源,匹配内容

HDU-6170 Two strings的更多相关文章

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

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

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

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

  3. HDU 6170 Two strings (dp)

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

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

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

  5. hdu 6170 Two strings dp

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

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

  7. HDU 6170 dp

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

  8. HDU 2736 Surprising Strings

                                    Surprising Strings Time Limit:1000MS     Memory Limit:65536KB     64 ...

  9. HDU 6170 FFF at Valentine(强联通缩点+拓扑排序)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6165 题意:给你一个无环,无重边的有向图,问你任意两点,是否存在路径使得其中一点能到达另一点 解析:强 ...

  10. hdu 2736 Surprising Strings(类似哈希,字符串处理)

    重点在判重的方法,嘻嘻 题目 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> int ...

随机推荐

  1. 第二次博客作业: 函数+进制转换器v1.0beta

    一:运行截图  二:介绍函数 1, int panduan1(int n,char a[],int count,int sign)//判断用户是否输入了除数字和a-f范围外的字符 { int i; ; ...

  2. 多层树级关系的json,递归删除空值的数据

    data =[{ "name": "省", "children":[ { "name": "市区", ...

  3. ICEM—气体罐子

    原视频下载地址:https://yunpan.cn/cPfzaLzkcFXVK  访问密码 62cf

  4. storm java环境变量设置

    storm启动时会加载conf/storm-env.sh文件 编辑 conf/storm-env.sh 添加export JAVA_HOME=/usr/java/jdk1.8.0_111

  5. Linux设备驱动程序 之 内核定时器

    综述 如果需要在将来的某个时间点调度执行某个动作,同时在该时间点到达之前不会阻塞当前进程,则可以使用内核定时器: 内核定时器是一个数据结构,它告诉内核在用户定义的时间点使用用户定义的参数来执行一个用户 ...

  6. GA函数优化

    一.遗传算法简介         遗传算法(Genetic Algorithms,GA)是1962年美国人提出,模拟自然界遗传和生物进化论而成的一种并行随机搜索最优化方法. 与自然界中“优胜略汰,适者 ...

  7. Python进行Redis数据迁移

    Python进行Redis数据迁移 由于开发时的误操作,导致redis数据损坏,所以需要进行redis的数据迁移,网上大佬的教程基本都是需要下载附加工具,亦或是需要一些复杂的操作,个人觉得麻烦还不如写 ...

  8. 自定义Camera的setPictureSize拍照完毕出现花屏怎么解决

    Camera.Parameters parameters = mCamera.getParameters();// 获得相机参数 List<Camera.Size> sizes = par ...

  9. React开发环境配置

    本文以上一篇文章继续配置:npm安装及环境配置<https://www.cnblogs.com/hzb462606/p/11565275.html> 使用 create-react-app ...

  10. k8s学习之资料参考网址(持续更新)

    此文章持续更新关于学习k8s生态的参考网址:  二进制方式搭建 (此部署方式是一步一步的部署,过程清晰)            https://github.com/opsnull/follow-me ...