#P11076. 「FSLOI Round I」单挑

    ID: 10424 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>数学洛谷原创O2优化洛谷月赛

「FSLOI Round I」单挑

Description

Exactly one of FL_sleake and SnowTrace will win a single one-on-one round. There is no situation of a tie.

Due to the uneven strength between FL_sleake and SnowTrace, they have made the rules as follow:

Given two positive integers xx and yy. If FL_sleake wins xx rounds before SnowTrace wins yy rounds, FL_sleake wins. Otherwise SnowTrace wins.

There have already been nn one-on-one rounds, and their results is given as a string ss of length nn. If the ii-th character of ss is F, it means FL_sleake has won the ii-th round. If the ii-th character of ss is S, it means SnowTrace has won the ii-th round.

FL_sleake wants to find the minimum number of the maximum winning streak in the following rounds of himself if he wins at last.

Input Format

Each test contains TT test cases.

The first line contains a single integer TT — the number of test cases. The description of test cases follows.

The first line of each test case contains three integers n,xn,x and yy.

The second line of each test case contains the string ss of length nn.

Output Format

For each test case, output one line containing a single integer, which is the answer of the test case.

1
5 6 4
SFSFS

4

1
3 7 3
FFF

2

1
29 1000 20
FFFSFFFFSFFFFFSFFFSFFFFFFSFFF

66

Hint

Example Explanation

In the first example, in order for FL_sleake to win, he must win all of the following rounds until he wins a total of 66 rounds. So, he has to win 44 times in a row.

In the second example, FFSFSF\texttt{FFSFSF} is a possible result of the following rounds. In this case, the maximum winning streak of FL_sleake is 22.

Note that you only needs to consider the maximum winning streak in the following rounds until he wins. The streak in the first nn rounds doesn't matter.

Constraints

Subtasks are used in this problem.

For all tests, it is guaranteed that:

  • 1T201 \leq T \leq 20
  • 1n2×1051 \leq n \leq 2\times10^5
  • 1x,y1091 \leq x,y \leq 10^9
  • in\forall i \leq n,SnowTrace doesn't win after the ii-th round.
  • i<n\forall i < n,FL_sleake doesn't win after the ii-th round.
Subtask Id Score Special Property
11 1010 n=1n=1
22 1515 x,ynx,y\leq n
33 AA
44 3030 T=1T=1
55 -
  • Special property AA: SnowTrace wins y1y-1 rounds after the nn-th round.