HDU6170 Two strings

题意:输入两个字符串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;
}
时间: 2024-10-22 18:53:00

HDU6170 Two strings的相关文章

43. Multiply Strings

1. 问题描述 Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input string to integer is NOT allowed.You should NOT use internal librar

Multiply Strings

package cn.edu.xidian.sselab;/** * title:Multiply Strings * content: * Given two numbers represented as strings, return multiplication of the numbers as a string. * Note: The numbers can be arbitrarily large and are non-negative. * 读已知条件可以,两个String转换

leetcode笔记:Isomorphic Strings

一.题目描述 Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of chara

LeetCode:Isomorphic Strings

1.题目名称 Isomorphic Strings(同构的字符串) 2.题目地址 https://leetcode.com/problems/isomorphic-strings/ 3.题目内容 英文: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurre

poj 2406 Power Strings KMP

Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative inte

go语言学习 strings常用函数

strings包中的函数用法 参考链接http://studygolang.com/articles/88 1.strings.replace() 函数原型 func Replace(str1, old, str2, n int) string //old是str1中的字符串,用str2替换str1中的old,一共替换n个.如果n<0,则全部替换 fmt.Println(strings.Replace("tet tet tet", "e", "es&

strings用法小记

By francis_hao    Feb 14,2017 打印文件中可打印字符,每个序列至少四(可配置)个字符长.主要用于显示非文本文件 概述 选项解释 -a --all - 扫描整个文件,不管那些段是否被加载或初始化,一般此项是默认的,除非程序被配置成-d的模式 -d --data 只打印初始化过或加载过的部分,此项可以减少一些垃圾数据. -f --print-file-name 在打印字符之前打印文件名 -min-len -n min-len --bytes=min-len 指定打印的最短

Power Strings(KMP)

Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 45008   Accepted: 18794 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "

[shiro] Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.

访问某页面时,出现了这个异常: java.lang.IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are properly formatted. at org.apache.shiro.authz.permission.WildcardPermission.setParts(WildcardPermission.java:154) at org.apa