HDU 6170
来源:互联网 发布:程序员的输入法 编辑:程序博客网 时间:2024/06/10 03:20
题目
Two strings
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1214 Accepted Submission(s): 504
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 “*”.
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).
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
3aaa*abba.*abbaab
传送门 :http://blog.csdn.net/algzjh/article/details/77484741
正则表达式,orz ,真的厉害
#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;}
阅读全文
0 0
- hdu 6170
- hdu 6170
- HDU 6170
- hdu 6170
- hdu 6170 Two strings
- HDU 6170:Two strings
- HDU 6170 Two strings
- hdu 6170 正则表达式
- hdu 6170 Two strings
- HDU-6170 Two strings
- hdu 6170 Two strings
- hdu 6170 模拟
- HDU 6170 Two strings
- HDU 6170 字符串Dp
- hdu-6170 Two strings
- hdu
- hdu
- HDU
- python—函数的可变参数与关键字参数
- 2017暑假第二阶段第三场 总结
- css布局——文档流布局、浮动布局
- POJ 1088滑雪
- [Leetcode] 366. Find Leaves of Binary Tree 解题报告
- HDU 6170
- 10分钟搞定pandas,分享共勉~
- 大数据领域的杰出公司(国内外2)
- ppt 2010 动画窗格 组合元素 使用方法
- register_chrdev_region函数解析
- n log n的最长上升子序列
- 抽象 关键字abstract与final使用
- android之频道管理
- (reading)Revisiting Visual Question Answering Baselines