HDU-6170 Two strings
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的更多相关文章
- HDU 6170 - Two strings | 2017 ZJUT Multi-University Training 9
/* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问 ...
- 2017多校第9场 HDU 6170 Two strings DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6170 题意:给了2个字符串,其中第2个字符串包含.和*两种特别字符,问第二个字符串能否和第一个匹配. ...
- HDU 6170 Two strings (dp)
/** * 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6170 * 字符串match, '.'代表匹配任意一个字符,"*" 代表 ...
- HDU 6170 Two strings( DP+字符串匹配)
http://acm.hdu.edu.cn/showproblem.php?pid=6170 题目大意: 给出两个字符串s1和s2(长度小于等于2500). s1是一个正常的包含大小写字母的字符串,s ...
- hdu 6170 Two strings dp
Two strings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Prob ...
- 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 ...
- HDU 6170 dp
Two strings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 2736 Surprising Strings
Surprising Strings Time Limit:1000MS Memory Limit:65536KB 64 ...
- HDU 6170 FFF at Valentine(强联通缩点+拓扑排序)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6165 题意:给你一个无环,无重边的有向图,问你任意两点,是否存在路径使得其中一点能到达另一点 解析:强 ...
- hdu 2736 Surprising Strings(类似哈希,字符串处理)
重点在判重的方法,嘻嘻 题目 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> int ...
随机推荐
- LOJ2341. 「WC2018」即时战略 [动态点分治]
LOJ 思路 考虑最蠢的暴力:枚举2~n,从1拉一条到他们的链,需要查询\(n^2\)次,显然不能通过. 考虑优化:如果拉的第一个点已经被访问过了,那么类似二分的做法,一次往那个方向多跳几步. 多跳几 ...
- 二十九、SELinux简介
一.基础 1)访问模型 Linux原有访问模型:自主访问控制 DAC 安全隐患: 进程所能访问资源的范围 为用户所能访问的资源范围 后门: rootkit程序 进程被胁持: 基于进程作为跳板,就有了进 ...
- 树莓派中将caplock映射为esc键
据说,喜欢vimer都呵caplock有仇,明明caplock占着原来esc的位置,却从来没有起到应有的作用,你说气人吗,没关系,我改啊:将下面语句加入到.bashrc中,启动即可xmodmap -e ...
- ASP.NET的MVC设计模式
当开发者听到“设计模式”这个词时,他们通常联想到两个场景.一组开发者正在讨论许多创造性意见,正在开会,但是却没有进行编码.另外一组人能制定出正确的计划,保证系统能够开发成功,代码可以重用. 而现实一般 ...
- Android5.0以下drawable tag vector错误的解决办法(转发)
Android5.0以下drawable tag vector错误的解决办法 在Androi 5.0以下的设备可能会报这样的错误: Caused by: org.xmlpull.v1.XmlPullP ...
- 论好的代码习惯的养成/做一个优雅的coder
1.先说一下以前被滴滴大佬教育的事情: 以前写代码的时候,因为只需要取特定的几个字段,所以经常这么写 //Request $request for example $parameters = $req ...
- About Xi’an
Introduction Ancient Capital It is the birthplace of the Chinese Nation, is one of the four ancient ...
- java中的异步处理和Feature接口(一)
背景介绍想象这样一个场景:你可能希望为你的法国客户提供指定主题的热点报道.为实现这一功能,你需要向 谷歌或者Twitter的API请求所有语言中针对该主题最热门的评论,可能还需要依据你的内部算法 对它 ...
- 001-多线程-JUC线程池-线程池架构-Executor、ExecutorService、ThreadPoolExecutor、Executors
一.概述 1.1.线程池架构图 1. Executor 它是"执行者"接口,它是来执行任务的.准确的说,Executor提供了execute()接口来执行已提交的 Runnable ...
- [C++]数据结构:线性表之(单)链表
一 (单)链表 ADT + Status InitList(LinkList &L) 初始化(单)链表 + void printList(LinkList L) 遍历(单)链表 + int L ...