LightOJ - 1338(Crawling in process...) Hidden Secret! (模拟)
2016-04-30 17:42
603 查看
LightOJ - 1338(Crawling in process...)
Hidden Secret!
Status
Description
In this problem you are given two names, you have to find whether one name is hidden into another. The restrictions are:
1. You can change some uppercase letters to lower case and vice versa.
2. You can add/remove spaces freely.
3. You can permute the letters.
And if two names match exactly, then you can say that one name is hidden into another.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with two lines. Each line contains a name consists of upper/lower case English letters and spaces. You can assume that the length of any name is between
1 and 100 (inclusive).
Output
For each case, print the case number and "Yes" if one name is hidden into another. Otherwise print
"No".
Sample Input
3
Tom Marvolo Riddle
I am Lord Voldemort
I am not Harry Potter
Hi Pretty Roar to man
Harry and Voldemort
Tom and Jerry and Harry
Sample Output
Case 1: Yes
Case 2: Yes
Case 3: No
Hint
Source
Problem Setter: Jane Alam Jan
//题意:
给出两个字符串,问一个字符串是否隐藏在另一个字符串中。(可以忽略大小写)
//思路:
直接模拟
Hidden Secret!
Time Limit: 1MS | Memory Limit: 32768KB | 64bit IO Format: %lld & %llu |
Description
In this problem you are given two names, you have to find whether one name is hidden into another. The restrictions are:
1. You can change some uppercase letters to lower case and vice versa.
2. You can add/remove spaces freely.
3. You can permute the letters.
And if two names match exactly, then you can say that one name is hidden into another.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with two lines. Each line contains a name consists of upper/lower case English letters and spaces. You can assume that the length of any name is between
1 and 100 (inclusive).
Output
For each case, print the case number and "Yes" if one name is hidden into another. Otherwise print
"No".
Sample Input
3
Tom Marvolo Riddle
I am Lord Voldemort
I am not Harry Potter
Hi Pretty Roar to man
Harry and Voldemort
Tom and Jerry and Harry
Sample Output
Case 1: Yes
Case 2: Yes
Case 3: No
Hint
Source
Problem Setter: Jane Alam Jan
//题意:
给出两个字符串,问一个字符串是否隐藏在另一个字符串中。(可以忽略大小写)
//思路:
直接模拟
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; char s1[1010],s2[1010]; int ch[1010]; int main() { int t,k=1; scanf("%d",&t); getchar(); while(t--) { memset(s1,0,sizeof(s1)); memset(s2,0,sizeof(s2)); memset(ch,0,sizeof(ch)); gets(s1); gets(s2); for(int i=0;i<strlen(s1);i++) { if(s1[i]==' ') continue; int op; if(s1[i]>='a'&&s1[i]<='z') { op=s1[i]-'a'; ch[op]++; } else if(s1[i]>='A'&&s1[i]<='Z') { op=s1[i]-'A'; ch[op]++; } } bool f=false; for(int i=0;i<strlen(s2);i++) { if(s2[i]==' ') continue; int op; if(s2[i]>='a'&&s2[i]<='z') { op=s2[i]-'a'; if(ch[op]!=0) ch[op]--; else f=true; } else if(s2[i]>='A'&&s2[i]<='Z') { op=s2[i]-'A'; if(ch[op]!=0) ch[op]--; else f=true; } } if(!f) printf("Case %d: Yes\n",k++); else printf("Case %d: No\n",k++); } return 0; }
相关文章推荐
- Java循环练习:打印图案-4
- 1041. 考试座位号(15)
- WPS 广告关闭
- WPS 广告关闭
- 1040. 有几个PAT(25)
- leetcode——92——Reverse Linked List II
- Spring中的AOP(六)——基于XML配置文件方式的AOP
- 大数整除(大数mod)
- ORA-01501: CREATE DATABASE failed
- VMWare10安装Centos6.5 32位网络配置问题
- 打字测试
- java 利用for循环打印九九乘法口诀
- XMG 导航控制器push的时候下一个控制器的时候view的加载
- Spring中的AOP(五)——定义切入点和切入点指示符
- Spring中的AOP(四)——在Advice方法中获取目标方法的参数
- Jquery中事件的绑定和解除
- 解决Centos关闭You have new mail in /var/spool/mail/root提示
- 传输层协议TCP和UDP
- Spring中的AOP(三)——基于Annotation的配置方式(二)
- Spring中的AOP(二)——基于Annotation的配置方式(一)