Substring ABC
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given a string S and the length of the string is N. You need to perform at most K operations (Possibly zero) of the string S.
In each operation,
You can choose an index \(i\), \(1<= i<= N\), right shift its character \(S[i]\).
Right shift means,
'a' becomes 'b',
'b' becomes 'c',
'c' becomes 'd',
...
'z' becomes 'a'.
After perfroming above operation on string S, find the occurrence of "abc" as a substring.
You need to perform operation such way that, total occurrence of "abc" is as maximum as possible.
Input
First line T, the number of test cases.
In each test case, first line two positive integers N and K.
Second line, a string S, the length of string is N.
\(1<=T<=500\)
\(1<= N <= 5000\)
\(1<= K <= 2 * 10^5\)
String S contains only lowercase alphabets.
Sum of N overall test case doesn't exceed 5000.
Output
In each test case, print the occurrence of abc of the string S.
Sample
Input | Output |
---|---|
|
|
First test case :
Brain Booster #6
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 9
- Start at
- 2024-10-03 15:30
- End at
- 2024-10-03 18:00
- Duration
- 2.5 hour(s)
- Host
- Partic.
- 151