Canadian Computing Competition: 2025 Stage 1, Senior #2
Cyrene, the captain of the Cryptogram Cracking Club (CCC), came across a concerningly long cipher. Conveniently, this cipher is composed of lower-case characters (a-z
). Comfortingly, the cipher is composed of a pattern that repeats infinitely.
Cyrene wishes to locate the aaaabccdddd
, the RLE algorithm outputs a4b1c2d4
.
You are given the output of the RLE algorithm for a certain pattern. Can you determine the
Input Specification
The first line of input will consist of a string
The next line of input contains a single integer
The following table shows how the available
Marks | Bounds on |
Additional Constraints |
---|---|---|
6 | All numbers appearing in |
|
3 | The length of the repeated pattern is at most |
|
3 | The length of the repeated pattern is at most |
|
3 | No additional constraints. |
Output Specification
Output the
Sample Input 1
r2d2
8
Sample Output 1
r
Explanation for Sample Output 1
The output of the RLE algorithm r2d2
corresponds to the pattern rrdd
, which creates the infinitely long cipher rrddrrddrrddrrdd...
, where the r
. In this example, the
Sample Input 2
a4b1c2d10
100
Sample Output 2
d
Explanation for Sample Output 2
The output of the RLE algorithm a4b1c2d10
corresponds to the pattern aaaabccdddddddddd
. When repeated infinitely, the d
.
Comments