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()求解由函数的形参传入的字符数组的长度时,得到的结果为指针的长度,既对应变量的字节数,而不是字符串的长度,此处一定要小心。

代码如下:

 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 }

原文地址:https://www.cnblogs.com/lu1nacy/p/10352387.html

时间: 2024-08-30 07:45:47

CodeCraft-19 and Codeforces Round #537 (Div. 2) A - Superhero Transformation的相关文章

CodeCraft-19 and Codeforces Round #537 (Div. 2) - D. Destroy the Colony(动态规划+组合数学)

Problem  CodeCraft-19 and Codeforces Round #537 (Div. 2) - D. Destroy the Colony Time Limit: 2000 mSec Problem Description Input Output For each question output the number of arrangements possible modulo 10^9+7. Sample Input abba21 41 2 Sample Output

贪心+构造 Codeforces Round #277 (Div. 2) C. Palindrome Transformation

题目传送门 1 /* 2 贪心+构造:因为是对称的,可以全都左一半考虑,过程很简单,但是能想到就很难了 3 */ 4 /************************************************ 5 Author :Running_Time 6 Created Time :2015-8-3 9:14:02 7 File Name :B.cpp 8 *************************************************/ 9 10 #include

CodeCraft-19 and Codeforces Round #537 (Div. 2) B. Average Superhero Gang Power

题目描述: Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations. Initially, there are nn superheroes in avengers tea

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

A. Superhero Transformation 水题,注意两个字符串可能长度不相等. #include<bits/stdc++.h> #define clr(a,b) memset(a,b,sizeof(a)) using namespace std; typedef long long ll; const int maxn=100010; map<char ,int >m; int main(){ m['a']=m['e']=m['i']=m['o']=m['u']=1;

[codeforces]Round #537 (Div. 2)E. Tree

题解:  q次查询每次查询k个点  k的总和不超过1e5  那就->虚树  这个题分为两部分  前面先对每次查询的点建虚树 其次计数  对于新树上的每个关键点(查询点)  他能影响的m的范围 必然大于以r为根的祖先节点的个数 然后我们单独考虑每个节点的贡献为 当前集合个数减去其祖先节点的个数  然后我们考虑把每个点按照dfs序的下标考虑贡献  转移分为两部分 1.当前元素加入直接构成一个新集合 2,当前元素加入可以加入到  m(当前集合个数)-祖先节点个数 #include <bits/std

【CodeCraft-19 and Codeforces Round #537 (Div. 2) C】Creative Snap

[链接] 我是链接,点我呀:) [题意] 横坐标1..2^n对应着2^n个复仇者的基地,上面有k个复仇者(位置依次给出). 你是灭霸你要用以下方法消灭这k个复仇者: 一开始你获取整个区间[1..2^n] 假设你当前获取的区间为[l,r] mid = (l+r)/2 那么你每次有两种选择 1.将整个区间全都毁掉,如果这个区间里没有复仇者,那么花费为A,否则花费为B复仇者个数区间长度 2.将区间分为[l,mid]和[mid+1,r]分开毁掉(即分别获取[l,mid]和[mid+1,r]这两个区间,然

CodeCraft-19 and Codeforces Round #537 (Div. 2) 题解

传送门 D. Destroy the Colony 首先明确题意:除了规定的两种(或一种)字母要在同侧以外,其他字母也必须在同侧. 发现当每种字母在左/右边确定之后,方案数就确定了,就是分组的方案数乘\(\frac{((n/2)!)^2}{\prod cnt_i!}\). 分组的方案数考虑DP,设\(dp_{i,j}\)为前\(i\)个字母,占了左边\(j\)个位置的方案数,则有: \[ dp_{i,j}=dp_{i-1,j-cnt_i}+dp_{i-1,j} \] 当\(i\)是指定字母时特判

Codeforces Round #514 (Div. 2) C. Sequence Transformation(递归)

C. Sequence Transformation 题目链接:https://codeforces.com/contest/1059/problem/C 题意: 现在有1~n共n个数,然后执行下面操作: 1.求出余下数的gcd,然后将gcd加入答案队列: 2.从中任意删除一个数,如果余下数的个数大于0,回到步骤1. 问答案队列字典序最大是什么. 题解: 这明明是递归在做极其方便,我偏偏用for循环来搞,加各种判断... 首先对于1,2,3...n来说,我们每次删去一个数时,肯定首先删去的是奇数

Codeforces Round #153 (Div. 1) C Number Transformation bfs

//到达2 , 3 ... k的最小公倍数为lcm //当x到达lcm的倍数时,x只能减一 //又从a到b一定会过lcm的倍数 //我们将a,b以lcm分割 //那么完整的lcm段的最小数是相同的,所以我们只需要计算一个lcm段的最小值乘以完整lcm段的个数 //以及首尾的不全的lcm段的和即为答案 #include<cstdio> #include<cstring> #include<iostream> #include<queue> using name