| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 48 | 21 | 19 | 52.778% |
It's the year 3000ドル,ドル and Bessie became the first cow in space! During her journey between the stars, she found a number line with $N$ (2ドル \leq N \leq 5 \cdot 10^5$) points, numbered from 1ドル$ to $N$. All points are initially colored white. She can perform the following operation any number of times.
Farmer John gives Bessie a string $s$ of length $N$ consisting of characters $R,ドル $B,ドル and $X$. The string represents Farmer John's color preferences for each point: $s_i=R$ means the $i$'th point must be colored red, $s_i = B$ means the $i$'th point must be colored blue, and $s_i = X$ means there is no constraint on the color for the $i$'th point.
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 10ドル^9+7$.
The first line contains an integer $N$.
The following line contains string $s$.
Output the number of distinct ways for the number line to be colored while satisfying Farmer John's preferences modulo 10ドル^9+7$.
6 RXXXXB
5
The other colorings are $RRBBRB,ドル $RBWWRB,ドル $RRRBBB,ドル and $RBRBRB$.
6 XXRBXX
6
The six colorings are $WWRBWW,ドル $WWRBRB,ドル $WRRBBW,ドル $RBRBWW,ドル $RBRBRB,ドル and $RRRBBB$.
12 XBXXXXRXRBXX
18