[UVA] 11713 - Abstract Names
I I U P C 2 0 0 9 |
|
|
|
Problem A: Abstract Names |
|
|
|
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 |
Output for Sample Input |
5 pele polo pele pola ronaldo ronaldino pele pelet pele bele |
Yes Yes No No No |
|
|
Problem Setter: Shamim Hafiz Special Thanks: Tanveer Ahsan |
這題考的是子音只能對子音(1對1), 而母音可以換成母音 (a,e,i,o,u 可以任意取代)
#include <stdio.h>
#include <string.h>
int main() {
char s1[100], s2[100];
int t, i;
int vowel[256] = {};
vowel['a'] = 1, vowel['e'] = 1, vowel['i'] = 1;
vowel['o'] = 1, vowel['u'] = 1;
scanf("%d", &t);
while(t--) {
scanf("%s %s", s1, s2);
if(strlen(s1) != strlen(s2)) {
puts("No");
continue;
}
int flag = 0;
for(i = 0; s1[i] && !flag; i++) {
if(vowel[s1[i]] || vowel[s2[i]]) {
if(vowel[s1[i]] != vowel[s2[i]])
flag = 1;
} else {
if(s1[i] != s2[i])
flag = 1;
}
}
puts(flag ? "No" : "Yes");
}
return 0;
}