#P6710. [BalticOI 2005] Ancient Manuscript (Day2)
[BalticOI 2005] Ancient Manuscript (Day2)
Problem Description
A Baltic string is defined as follows:
- It consists only of lowercase letters.
- It contains at most consecutive vowels.
- It contains at most consecutive consonants.
- It contains at most consecutive equal vowels.
- It contains at most consecutive equal consonants.
aeiou are vowels. The other 21 letters are consonants.
Now you are given a string in which some characters are lowercase letters and some characters are *. You may replace each * with any lowercase letter.
Find the number of different Baltic strings that can be obtained from this string by performing such replacements.
Input Format
The first line contains four integers , whose meanings are given in the description.
The second line contains a string, whose meaning is given in the description.
Output Format
Output one integer: the number of different Baltic strings that can be obtained from the string after replacements.
It is guaranteed that the answer fits in a 64-bit signed integer.
1 1 1 1
a**
105
1 1 1 1
b*i
0
1 2 1 2
ancient
1
4 4 4 4
man****ipt
261870
2 2 2 2
*boi*
546
Hint
Constraints
For of the testdata, , , and the length of the string .
Notes
Translated from BalticOI 2005 Day2 A Ancient Manuscript。
Translated by ChatGPT 5