[Solution] Closest Vowels CodeChef Solution | CodeChef Problem Solution 2022
Chef considers a string consisting of lowercase English alphabets beautiful if all the characters of the string are vowels.
Chef has a string consisting of lowercase English alphabets, of length . He wants to convert into a beautiful string . In order to do so, Chef does the following operation on every character of the string:
- If the character is a consonant, change the character to its closest vowel.
- If the character is a vowel, don't change it.
Chef realizes that the final string is not unique. Chef wonders, what is the total number of distinct beautiful strings that can be obtained by performing the given operations on the string .
Since the answer can be huge, print it modulo .
Note:
- There are characters in the English alphabet. Five of these characters are vowels:
a
,e
,i
,o
, andu
. The remaining characters are consonants. - The closest vowel to a consonant is the vowel that is least distant from that consonant. For example, the distance between the characters
d
ande
is while the distance between the charactersd
anda
is . - The distance between the characters
z
anda
is and not .
Input Format
- The first line of input will contain an integer — the number of test cases. The description of test cases follows.
- The first line of each test case contains an integer , denoting the length of the string .
- The second line of each test case contains a string consisting of lowercase English alphabets.
Output Format
For each test case, output the total number of distinct beautiful strings that can be obtained by performing the given operations on the string , modulo .
Constraints
- Sum of over all test cases does not exceed .
No comments:
Post a Comment