HDU6170-Two strings
来源:互联网 发布:汽车刷ecu软件 编辑:程序博客网 时间:2024/06/03 20:09
Two strings
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 274 Accepted Submission(s): 90
Problem Description
Giving two strings and you should judge if they are matched.
The first string contains lowercase letters and uppercase letters.
The second string contains lowercase letters, uppercase letters, and special symbols: “.” and “*”.
. can match any letter, and * means the front character can appear any times. For example, “a.b” can match “acb” or “abb”, “a*” can match “a”, “aa” and even empty string. ( “” will not appear in the front of the string, and there will not be two consecutive “”.
Input
The first line contains an integer T implying the number of test cases. (T≤15)
For each test case, there are two lines implying the two strings (The length of the two strings is less than 2500).
Output
For each test case, print “yes” if the two strings are matched, otherwise print “no”.
Sample Input
3
aa
a*
abb
a.*
abb
aab
Sample Output
yes
yes
no
Source
2017 Multi-University Training Contest - Team 9
题目大意:问给出的正则表达式能否匹配文本。
解题思路:利用
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<regex>using namespace std;const int MAXN=2600;string s,p;int main(){ int T; cin>>T; while(T--) { cin>>s>>p; string s1=".*"; string s2="(a*|b*|c*|d*|e*|f*|g*|h*|i*|j*|k*|l*|m*|n*|o*|p*|q*|r*|s*|t*|u*|v*|w*|x*|y*|z*" "|A*|B*|C*|D*|E*|F*|G*|H*|I*|J*|K*|L*|M*|N*|O*|P*|Q*|R*|S*|T*|U*|V*|W*|X*|Y*|Z*)"; //string s2="(.)\\1*"; int len=s2.length(); auto pos=p.find(s1); while(pos!=string::npos) { p.replace(pos,2,s2); pos=p.find(s1,pos+len); } regex pat(p); if(regex_match(s,pat)) cout<<"yes"<<endl; else cout<<"no"<<endl; } return 0;}
- HDU6170-Two strings
- HDU6170-Two strings
- hdu6170 Two strings【regex真好用】
- [正则表达式] hdu6170 two strings
- Two strings hdu6170 dp递推
- HDU6170-Two strings 多校9 dp
- HDU6170 Two strings(动态规划)
- hdu6170-多看几遍之DP&递推&字符串-Two strings
- HDU6170 Two strings dp 多校联赛第9场
- HDU6170 Two strings(dp,2017 HDU多校联赛 第9场)
- hdu6170
- Two Strings
- BNU29375:Two Strings
- BNU 29375 Two Strings
- Two Strings Are Anagrams
- Two Strings Are Anagrams
- Two Strings Are Anagrams
- Two Strings Are Anagrams
- hive优化-压缩处理
- HDU 6162 Ch’s gift (2017多校9
- Android 8.0 新特性了
- map()函数
- RxJava笔记
- HDU6170-Two strings
- nyoj32组合数
- 迭代(python笔记)
- 安卓开发 color表
- springboot基本使用笔记----添加jsp支持及打包部署
- 安卓_缓存
- iOS 开发
- Confluence5.10.8安装教程
- 京东笔试题——集合