Caillou has designed a Run-Length Encoding (RLE) challenge for you.
The task is to define the class ‘RLECodec’ for run-length encoding:
The rule of run-length encoding is simple: Count the number of consecutive repeated characters in a string, and replace the repeated characters by the count and a single instance of the character. For example, if the input string is ‘AAADDDDDDDBBGGGGGCEEEE’, its run-length encoding will be ‘3A7DBB5GC4E’, because there are three A’s, seven D’s, … etc. Note that we do not need to encode runs of length one or two, since ‘2B’ and ‘1C’ are not shorter than ‘BB’ and ‘C’.
You need to perform T queries on an encoded string, where each query returns the positions (1-based indexes) of a character C in the decoded string.
This problem is a partial judge.
Please implement functions defined in the header file.
decode: Decode the string.
getPos: Return an array of 1-based positions for character C, terminated by 0.
The first line contains an encoded string S. In every <count><character> pair, the count is guaranteed to be less than or equal to 15.
The second line contains an integer T, indicating the number of queries.
Each of the next T lines contains a character C, querying for all positions of C in the decoded string. C is guaranteed to be an uppercase letter.
1 ≤ |S| ≤ 150
The first line outputs the decoded string of S.
Each of the next T lines outputs all positions of the corresponding C in the decoded string.