Logo
(追記) (追記ここまで)

32741번 - Illuminated Lights II 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB87787.500%

문제

There are $n$ lights in a row, all initially deactivated. Some lights, when activated, will illuminate themselves and all lights to their left. The others, when activated, will illuminate themselves and all lights to their right.

This image shows the result of activating the fourth light (and nothing else) in the first sample case. The first four lights are illuminated, and everything else is not.

You have already figured out the minimum number of lights that need to be activated to illuminate everything, but now, you're wondering how many good subsets of lights exist.

A subset $S$ of the lights is considered good if when you activate the lights in $S$ (and only the lights in $S$), every light on the row is illuminated.

How many good subsets are there? Since the answer may be large, output it modulo 10ドル^9+7$.

입력

The first line of the input contains a single integer $t$ (1ドル \le t \le 10^4$) --- the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ (1ドル \le n \le 2\cdot 10^5$) --- the number of lights.

The next line of each test case contains a string $s$ consisting of $n$ characters L and R, indicating whether the lights are pointed to the left or right.

It is guaranteed that the sum of $n$ over all test cases does not exceed 2ドル\cdot 10^5$.

출력

For each test case, print a single integer --- the number of good subsets, taken modulo 10ドル^9+7$.

제한

예제 입력 1

7
6
LRRLRL
1
L
2
RL
2
LR
5
RRRRL
10
LRLRLRLRLR
31
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

예제 출력 1

50
1
3
1
24
912
73741817

힌트

For the second and fourth test cases, the only way to illuminate everything is to activate every light. Therefore, for these cases, the only good subset is the set containing all lights.

For the third test case, as long as either of the two lights is activated, everything will be illuminated. Therefore, the sets $\{1\},ドル $\{2\},ドル and $\{1, 2\}$ are good.

출처

University > Rutgers University > Rutgers Programming Contest Fall 2024 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /