Problem Description
source:https://uva.onlinejudge.org/external/117/11713.html
Some of you may have noticed that in certain computer games, particularly the ones based on sports, the spelling of names are mutated so that they are not an exact duplicate of the real entity. This is done to avoid hassles of taking permission from each player as well as any patent issues. In this problem, you will be given a pair of names, one of which is that of a player in real life and the second found in a game. You will have to determine if the two names are same, that is the second one is obtained by mutating the first.
Two names are considered same if they are of same length and they only vary at positions where vowels occur. That means, a name which can be obtained by replacing zero or more vowels by other vowels to obtain a new name are considered same, provided they have same length. For example, both polo and pola are same as pele but not pelet or bele.
Input
First line of input contains a positive integer n ≤ 20, where n denotes the number of test cases. This will be followed by 2 ∗ n lines where each line will contain a name of at most 20 characters. The names will consist of lower case letters only.
Output
For each case of input, there will be one line of output. It will be ‘Yes’ if the second name can be obtained by mutating the first name, otherwise it will be ‘No’.
Sample Input
5
pele
polo
pele
pola
ronaldo
ronaldino
pele
pelet
pele
bele
Sample Output
Yes
Yes
No
No
No
source:https://uva.onlinejudge.org/external/117/11713.html
Some of you may have noticed that in certain computer games, particularly the ones based on sports, the spelling of names are mutated so that they are not an exact duplicate of the real entity. This is done to avoid hassles of taking permission from each player as well as any patent issues. In this problem, you will be given a pair of names, one of which is that of a player in real life and the second found in a game. You will have to determine if the two names are same, that is the second one is obtained by mutating the first.
Two names are considered same if they are of same length and they only vary at positions where vowels occur. That means, a name which can be obtained by replacing zero or more vowels by other vowels to obtain a new name are considered same, provided they have same length. For example, both polo and pola are same as pele but not pelet or bele.
Input
First line of input contains a positive integer n ≤ 20, where n denotes the number of test cases. This will be followed by 2 ∗ n lines where each line will contain a name of at most 20 characters. The names will consist of lower case letters only.
Output
For each case of input, there will be one line of output. It will be ‘Yes’ if the second name can be obtained by mutating the first name, otherwise it will be ‘No’.
Sample Input
5
pele
polo
pele
pola
ronaldo
ronaldino
pele
pelet
pele
bele
Sample Output
Yes
Yes
No
No
No
Solution:
#include <algorithm> #include <cstdio> #include <cmath> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include<stdio.h> #include<stdlib.h> int main() { int i, j, t, len1, len2; char name1[23], name2[23]; while(scanf("%d",&t)==1) { for(i=1;i<=t;i++) { scanf("%s", &name1); scanf("%s", &name2); len1=strlen(name1); len2=strlen(name2); if(len1!=len2) { printf("No\n"); } else { for(j=0;j<len1;j++) { if((name1[j]=='a'||name1[j]=='e'||name1[j]=='i'||name1[j]=='o'||name1[j]=='u') && (name2[j]=='a'||name2[j]=='e'||name2[j]=='i'||name2[j]=='o'||name2[j]=='u')) { continue; } else if(name1[j]==name2[j]) { continue; } else break; } if(len1==j) printf("Yes\n"); else printf("No\n"); } } } return 0; }
input 4(4*2) ta nea jae but 5 tar 1st name input hoy 2nd ta hoy na kem?
ReplyDelete