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. Git入门(待更)

    github是什么? 以下截取自百度百科 github: GitHub 是一个面向开源及私有软件项目的托管平台,因为只支持 Git 作为唯一的版本库格式进行托管,故名 GitHub. GitHub 于 ...

  2. pxe linux 0

    操作环境:windows 实验环境:vmware workstation 实验要求:配置一台workstation机器(ip地址192.168.96.100 gateway 192.168.96.2 ...

  3. ie8 ajax 跨域问题

    最近做了个客服端要通过ocx获得初始化数据就是一个html页面镶嵌在一个c++做的程序里面通过c++做的程序的一个按钮来打开我的这个html页面但是页面中的ajax就是用不了又不报错 后来加入了cro ...

  4. 一个U盘制作多个系统

    写在前面:一个U盘可以装多个ghost系统,但不能装多个原版ISO系统. 一.一个U盘装多个ghost系统 下载老毛桃或电脑店U盘制作工具,点击一键制作U盘启动盘.然后将gho文件拷贝复制到U盘的GH ...

  5. python与统计(龙族版)

    因为我很喜欢龙族,额........我也很喜欢python这门语言.然后就结合了一下,用python了解了一下龙族四本书的人物出场次数及排名. <龙族1火之晨曦> 路明非 1877 诺诺 ...

  6. Node.js中npm常用命令大全

    npm是什么 NPM的全称是Node Package Manager,是随同NodeJS一起安装的包管理和分发工具,它很方便让JavaScript开发者下载.安装.上传以及管理已经安装的包. npm ...

  7. spring boot 学习常用网站

    springboot的特性 https://www.cnblogs.com/softidea/p/5644750.html 1.自定义banner https://www.cnblogs.com/cc ...

  8. arcgis python 随机取部分数据

    # -*- coding: cp936 -*- import arcpy import os import ylpy import random def main(): num=ylpy.getCou ...

  9. Ubuntu 18.04安装arm-linux-gcc交叉编译器(超简单,附安装包下载地址)

    目前网上搜索发现,最多人安装的是4.4.3版本的: arm-linux-gcc-4.4.3.tar.gz下载地址:https://pan.baidu.com/s/1rAIBASIRZAXl-P1UOW ...

  10. 分组背包---P1757 通天之分组背包

    P1757 通天之分组背包 题解 分组背包板子题 k组物品,每组之间相互矛盾,也就是一组里面只能选一个或者不选 分组背包其实和01背包差不多,就是多加一维枚举组数 f[k][j] 前k组中,体积不超过 ...