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. [Hdoj] Fast Matrix Calculation

    题面:http://acm.hdu.edu.cn/showproblem.php?pid=4965 题解:https://www.zybuluo.com/wsndy-xx/note/1153981

  2. ZOJ 3182 HDU 2842递推

    ZOJ 3182 Nine Interlinks 题目大意:把一些带标号的环套到棍子上,标号为1的可以所以操作,标号i的根子在棍子上时,只有它标号比它小的换都不在棍子上,才能把标号为i+1的环,放在棍 ...

  3. js和jQuery实现的Ajax

    1. JS实现Ajax <!doctype html> <html lang="en"> <head> <meta charset=&qu ...

  4. LVM问题-----Insufficient Free Extents for a Logical Volume

    Linux LVM学习——Insufficient Free Extents for a Logical Volume 如下所示,在创建LV的时候,偶尔会遇到“Volume group "x ...

  5. EGL Driver message (Critical) eglInitialize: No available renderers.

    使用Python的selenium库进行自动化巡检.并将相对应的数据保存 环境: Windows Embedded Standard Python 2.7.16 selenium 3.141.0 [0 ...

  6. HTTP header 介绍 转载

    这篇文章为大家介绍了HTTP头部信息,中英文对比分析,还是比较全面的,若大家在使用过程中遇到不了解的,可以适当参考下 HTTP 头部解释 1. Accept:告诉WEB服务器自己接受什么介质类型,*/ ...

  7. [题解] [SDOI2017] 序列计数

    题面 题解 和 SDOI2015 序列统计 比较像 这个无非就是把乘改成了加, NTT 改成了 MTT 再加上了一个小小的容斥 : 拿所有方案减去不合法方案即可 Code #include <a ...

  8. gdb常用的调试命令

    首先将源代码编译.链接生成debug版本的可执行文件,然后通过‘gdb  debug版本的可执行文件名’进入调试模式. a) 单进程.单线程基础调试命令 l    显示main函数所在的文件的源代码 ...

  9. 文本处理三剑客之awk

    简介 awk是一种处理文本文件的语言,是一个强大的文本编辑工具.简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分在进行各种分析处理. gawk 用法:gawk [optio ...

  10. java课后实验性问题1

    一.一个java类文件中只能有一个公有类吗? 测试代码 public class Test{ public static void main(String[] args){ } public clas ...