#P14113. [IAMOI R4] 彻底怒了

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

[IAMOI R4] 彻底怒了

Description

General Gold has two strings ss and tt, each of length nn. He defines the fury value of a string as the number of occurrences of the substring CDNL.

Now, he wants to select a substring ss' from ss with length at most mm, and a substring tt' from tt with length at most kk, such that the concatenated string s+ts' + t' (in this order) maximizes the fury value. You need to help him find this value.

A substring is a contiguous sequence of characters from the original string.

Input Format

There are multiple test cases.

The first line contains an integer TT, indicating the number of test cases.

For each test case:

  • The first line contains three positive integers nn, mm, kk.
  • The second line contains a string ss of length nn.
  • The third line contains a string tt of length nn.

Output Format

For each test case, output one line containing a single integer—the answer.

2
4 4 4
CDNL
CDNL
2 2 2
CD
NL
2
1

Hint

【Sample Explanation】

For the first test case, the optimal concatenated string is CDNLCDNL, which contains 22 occurrences of CDNL, so the fury value is 22.

For the second test case, the optimal concatenated string is CDNL, which contains 11 occurrence of CDNL, so the fury value is 11.

【Constraints】

Test Point nn \leq m,km, k Points
11 10510^5 =n=n 2020
22 1010 n\leq n 3030
33 100100 ^ 2020
44 10510^5 10\leq 10 ^
55 ^ n\leq n 1010

For all test cases, it is guaranteed that: 1T101 \le T \le 10, 1n,m,k1051 \le n, m, k \le 10^5, and ss, tt consist only of uppercase letters C, D, N, L.