Cipher
InterviewTime limit2sMemory limit1024 MB
Count the lengths k for which the prefix and suffix of length k contain the same nonzero number of vowels, with uppercase vowels included.
- Level
Easy3 of 10
- Topics
- String, Prefix sum
- Solved
- No attempts yet
Statement
Lea Organa urgently needs your help! The Jedi Order has intercepted a message from Tatooine that was probably meant for the Sith Order. The message should contain a lot of information, including data that interests the Light Side. However, it may also be disinformation meant to confuse the brave fighters against evil.
As a defector reported, the reliability of the message depends on the number of interesting pairs of prefixes and suffixes of equal length. A prefix of length can form an interesting pair with a suffix of the same length if both contain the same nonzero number of vowels. In the Star Wars universe, the vowels are the letters a, o, u, i, and e.
Unfortunately, our allies do not yet know how the reliability of the message relates to the number of such pairs. They will find out later. For now, Lea asks you to count the interesting pairs of prefixes and suffixes.
Input
The first line contains an integer (), the length of the encrypted string. The second line contains the message itself, which consists only of lowercase and uppercase Latin letters.
Output
Print one number: the count of positive integers such that the prefix and the suffix of length contain the same nonzero number of vowels.
Hint
Remember that uppercase vowels count as vowels too.