#P4051. Circle-Based String Encryption
Circle-Based String Encryption
Circle-Based String Encryption
This problem introduces a novel encryption technique. Given an input string S of length n, consider arranging the characters in a circle. From this circle, generate all cyclic rotations of S. Specifically, the i-th rotation (for 0 ≤ i < n) is given by:
\( R_i = s_i s_{(i+1) \mod n} s_{(i+2) \mod n} \ldots s_{(i-1) \mod n} \)
Sort all the rotations in lexicographical order resulting in ordered rotations \( R'_0, R'_1, \ldots, R'_{n-1} \). The encrypted string is then constructed by concatenating the last character of each sorted rotation:
\( E = \text{last}(R'_0)\, \text{last}(R'_1) \ldots \text{last}(R'_{n-1}) \)
Your task is to implement this encryption method.
inputFormat
The input consists of a single line containing the string S that needs to be encrypted. The string S is non-empty and may consist of letters and digits.
outputFormat
Output the encrypted string, produced by the described method.
sample
JSOI07
I0O7SJ