#691
Unrated
Interstellar Intervals
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

It's the year 30003000, and Bessie became the first cow in space! During her journey between the stars, she found a number line with NN (2N51052 \leq N \leq 5 \cdot 10^5) points, numbered from 11 to NN. All points are initially colored white. She can perform the following operation any number of times.

Choose a position ii within the number line and a positive integer xx. Then, color all the points in the interval [i,i+x1][i, i + x - 1] red and all points in [i+x,i+2x1][i + x, i + 2x - 1] blue. All chosen intervals must be disjoint (i.e. no points in [i,i+2x1][i, i + 2x - 1] can be already colored red or blue). The entire interval must also fall within the number line (i.e. 1ii+2x1N1 \leq i \leq i + 2x - 1 \leq N).

Farmer John gives Bessie a string ss of length NN consisting of characters RR, BB, and XX. The string represents Farmer John's color preferences for each point: si=Rs_i=R means the ii'th point must be colored red, si=Bs_i = B means the ii'th point must be colored blue, and si=Xs_i = X means there is no constraint on the color for the ii'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 109+710^9+7.

입력

The first line contains an integer NN.

The following line contains string ss.

출력

Output the number of distinct ways for the number line to be colored while satisfying Farmer John's preferences modulo 109+710^9+7.

예제 입력 1

6
RXXXXB

예제 출력 1

5

예제 입력 2

6
XXRBXX

예제 출력 2

6

예제 입력 3

12
XBXXXXRXRBXX

예제 출력 3

18

점수

Input 4: N500N\le 500Inputs 5-6: N104N\le 10^4Inputs 7-13: All but at most 100100 characters in ss are XX.Inputs 14-23: No additional constraints

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.