Problems
It's the year
Choose a position
Farmer John gives Bessie a string
Help Bessie count the number of distinct ways for the number line to be colored while satisfying Farmer John's preferences. Two colorings are different if there is at least one corresponding point with a different color. Because the answer may be large, output it modulo
Input
The first line contains an integer
The following line contains string
Output
Output the number of distinct ways for the number line to be colored while satisfying Farmer John's preferences modulo
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 10 | |
| #2 | 20 | |
| #3 | 30 | All but at most |
| #4 | 40 | No additional constraints |
Example #1
6
RXXXXB
5
Bessie can choose
The other colorings are
Example #2
6
XXRBXX
6
The six colorings are
Example #3
12
XBXXXXRXRBXX
18