CodeCraft-19 and Codeforces Round #537 (Div. 2) A - Superhero Transformation

题目描述

We all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name ss can transform to another superhero with name tt if ss can be made equal to tt by changing any vowel in ss to any other vowel and any consonant in ss to any other consonant. Multiple changes can be made.

In this problem, we consider the letters 'a', 'e', 'i', 'o' and 'u' to be vowels and all the other letters to be consonants.

Given the names of two superheroes, determine if the superhero with name ss can be transformed to the Superhero with name tt.

Input

The first line contains the string ss having length between 11 and 10001000, inclusive.

The second line contains the string tt having length between 11 and 10001000, inclusive.

Both strings ss and tt are guaranteed to be different and consist of lowercase English letters only.

Output

Output "Yes" (without quotes) if the superhero with name ss can be transformed to the superhero with name tt and "No" (without quotes) otherwise.

You can print each letter in any case (upper or lower).

Examples
input
a
u
output
Yes
input
abc
ukm
output
Yes
input
akm
ua
output
No
Note

In the first sample, since both 'a' and 'u' are vowels, it is possible to convert string ss to tt.

In the third sample, 'k' is a consonant, whereas 'a' is a vowel, so it is not possible to convert string ss to tt.

 

思路:签到题,就是元音和辅音相同位置的相同的话,输出Yes,不同的话输出No;

注意

strlen()函数求出的字符串长度为有效长度,既不包含字符串末尾结束符 ‘\0’;
sizeof()操作符求出的长度包含字符串末尾的结束符 ‘\0’;
当在函数内部使用sizeof()求解由函数的形参传入的字符数组的长度时,得到的结果为指针的长度,既对应变量的字节数,而不是字符串的长度,此处一定要小心。

 string类的size()/length()方法返回的是字节数,不管是否有汉字。

例:

string str="0123456789";
cout <<"str.length()="<<str.length()<<endl;//结果为10
cout <<"str.size()="<<str.size()<<endl;//结果为10

代码如下:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 
 5 int vow(char a,char b)
 6 {
 7     if(a == b)
 8     return 1;
 9     else if(a == 'a' || a == 'o' || a == 'e' || a == 'i' || a == 'u')
10     {
11         if(b == 'a' || b == 'o' || b == 'e' || b == 'i' || b == 'u')//元元
12         return 1;
13         else//元辅
14         return 0;
15     }
16     else if(b == 'a' || b == 'o' || b == 'e' || b == 'i' || b == 'u')//辅元
17     return 0;
18     //辅辅
19     return 1;
20 }
21 int main()
22 {
23     string s,t;
24     while(cin >> s >> t)
25     {
26         int sl = s.size();
27         int tl = t.size();
28         if(sl != tl)
29         {
30             cout << "No" << endl;
31             continue;
32         }
33         bool flag = 0;
34         for(int i = 0;i < sl;i++)
35         {
36             if(vow(s[i],t[i]) == 0)
37             {
38                 cout << "No" << endl;
39                 flag = 1;
40                 break;
41             }
42         }
43         if(flag == 0)
44         cout << "Yes" << endl;
45     }
46     return 0;
47 }

 

posted @ 2019-02-04 23:38  lu_nacy  阅读(275)  评论(0编辑  收藏  举报