#P14113. [IAMOI R4] 彻底怒了
[IAMOI R4] 彻底怒了
Description
General Gold has two strings and , each of length . He defines the fury value of a string as the number of occurrences of the substring CDNL.
Now, he wants to select a substring from with length at most , and a substring from with length at most , such that the concatenated string (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 , indicating the number of test cases.
For each test case:
- The first line contains three positive integers , , .
- The second line contains a string of length .
- The third line contains a string of length .
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 occurrences of CDNL, so the fury value is .
For the second test case, the optimal concatenated string is CDNL, which contains occurrence of CDNL, so the fury value is .
【Constraints】
| Test Point | Points | ||
|---|---|---|---|
| ^ | |||
| ^ | |||
| ^ |
For all test cases, it is guaranteed that: , , and , consist only of uppercase letters C, D, N, L.
京公网安备 11011102002149号