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. learning express step(十二)

    learning express view engine function const express = require('express'); const app = express(); app ...

  2. [Luogu] 聪聪可可

    题面:https://www.luogu.org/problemnew/show/P2634#sub 题解:https://www.zybuluo.com/wsndy-xx/note/1141506

  3. [Poj] Roads in the North

    http://poj.org/problem?id=2631 树的直径裸题 dfs/bfs均可 /* dfs */ #include <iostream> #include <cst ...

  4. 文件对比工具 Beyond Compare 4.2.9中文破解版for mac

    链接:https://pan.baidu.com/s/1AsESVIYsn9Lv6qz2TfROrQ 密码:6o63链接:https://pan.baidu.com/s/1eiGgRHfPTEERlH ...

  5. PHP 之验证码类封装

    一.效果图 二.类代码 <?php /** * Created by PhpStorm. * User: Yang * Date: 2019/8/13 * Time: 10:51 */ clas ...

  6. csp-s模拟110

    倒计时三天. 这场又是巨头们的AK场,大众分200+,貌似真实的csps? 然而T1又炸了,$1<<62$暴int,要$1ll<<62$.T2试图打70部分分,T3也只会40分 ...

  7. nginx 记录

    正则 ~ 区分大小写匹配 ~* 不区分大小写匹配 !~和!~*分别为区分大小写不匹配及不区分大小写不匹配 ^ 以什么开头的匹配 $ 以什么结尾的匹配 转义字符\ 可以转. * ?等 * 代表任意字符 ...

  8. Socket概述

    Socket套接字概述: 网络上具有唯一标识的IP地址和端口号组合在一起才能构成唯一能识别的标识符套接字. 通信的两端都有Socket. 网络通信其实就是Socket间的通信. 数据在两个Socket ...

  9. 13 Flutter仿京东商城项目 商品列表筛选以及上拉分页加载更多

    ProductList.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper.dart'; imp ...

  10. Qt编写自定义控件36-图片浏览器

    一.前言 本控件主要用来作为一个简单的图片浏览器使用,可以上下翻页显示图片,图片还可以开启过度效果比如透明度渐变,应用场景有查看报警图片运行图片等.此控件非本人原创,来源于网络,我只是修正了好多处BU ...