Lightoj1338——Hidden Secret!(模拟)
来源:互联网 发布:js中使用java变量 编辑:程序博客网 时间:2024/05/13 06:51
In this problem you are given two names, you have to find whether one name is hidden into another. The restrictions are:
- You can change some uppercase letters to lower case and vice versa.
- You can add/remove spaces freely.
- 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
Output for Sample Input
Case 1: Yes
Case 2: Yes
Case 3: No
主要是题意看了好久才懂。。。。
其实就是求两串字符串的字母是否一样,部分大小写
#include <iostream>#include <cstring>#include <string>#include <vector>#include <queue>#include <cstdio>#include <set>#include <cmath>#include <algorithm>#define INF 0x3f3f3f3f#define MAXN 2005#define Mod 10001using namespace std;char a[MAXN],b[MAXN];int aa[MAXN],bb[MAXN];bool check(char &a){ if(a>='a'&&a<='z') { a-=32; return true; } if(a>='A'&&a<='Z') return true; return false;}int main(){ int t,cnt=1; scanf("%d",&t); getchar(); while(t--) { gets(a); gets(b); memset(aa,0,sizeof(aa)); memset(bb,0,sizeof(bb)); int lena=strlen(a),lenb=strlen(b); for(int i=0; i<lena; ++i) { if(check(a[i])) aa[a[i]-'A']++; } for(int i=0; i<lenb; ++i) { if(check(b[i])) bb[b[i]-'A']++; } bool flag=true; for(int i=0;i<26;++i) if(bb[i]!=aa[i]) flag=false; printf("Case %d: ",cnt++); if(flag) printf("Yes\n"); else printf("No\n"); } return 0;}
- Lightoj1338——Hidden Secret!(模拟)
- Lightoj--1338--Hidden Secret!(模拟)
- LightOJ 1338-Hidden Secret!【模拟】
- LightOJ - 1338(Crawling in process...) Hidden Secret! (模拟)
- Hidden String(模拟)
- <LightOJ 1338> Hidden Secret!
- Google Android Hidden Secret Codes
- light oj 1338 - Hidden Secret!
- LightOJ - 1042 Secret Origins (模拟)水
- Light oj 1338 - Hidden Secret!【字符串】
- The Secret Garden——3、Finding the secret garden
- Secret Research ——字符串
- CSS Secret——Shapes
- CSS Secret——Typography
- Hidden Secret Codes for Google Android Mobile Phones
- 20150514: Opinion: The secret corporate takeover hidden in the TPP
- once his body was hidden in the secret alcove it
- Chemical Secret——2、At home
- 信号量与互斥锁的区别
- Java如何给极光推送发消息
- CCF 201509-1 数列分段
- JavaScript深入浅出——数据类型(一)
- Java-NowCoder-取近似值
- Lightoj1338——Hidden Secret!(模拟)
- C++中各种基本数据类型转换为string类型
- zip压缩算法分析(2)
- 匿名对象
- Codeforces Round #341 (Div. 2) D. Rat Kwesh and Cheese
- nyoj 325 和 nyoj 456【经典dp】
- 归并排序-《算法导论》学习笔记二
- 迭代器
- 【历史】JavaScript和Java没啥关系!————JavaScript简史