码迷,mamicode.com
首页 > 其他好文 > 详细

HDU6170 Two strings

时间:2017-08-22 20:53:08      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:pac   regex   while   max   turn   log   its   logs   sync   

题意:输入两个字符串l<2500,判断第二个字符串能不能匹配第一个字符串.代表任意字符×代表前面一个字符出现任意次

题解:dp,这里用正则表达式写了。。

#include <bits/stdc++.h>
#define maxn 2550
using namespace std;
string s1, s2, pa;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--){
        cin>>s1>>s2;
        pa = "";
        for(int i=0;i<s2.size();i++){
            if(s2[i+1] == *&&s2[i] == .) pa += "([a-zA-Z])(\\1)*", i++;
            else pa += s2[i];
        }
        printf("%s\n", regex_match(s1, regex(pa))?"yes":"no");
    }
    return 0;
}

 

HDU6170 Two strings

标签:pac   regex   while   max   turn   log   its   logs   sync   

原文地址:http://www.cnblogs.com/Noevon/p/7413479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!