ZOJ Problem Set - 1477
Much effort has been made to raise compression ratios. In recent years someone comes up with a method that rearranges the original file, so that they obtain higher compression ratio. It goes like this:
Original String, S: example
1) Make n string from S (n is the length of S). The ith string is made from
i-1th string by shifting left one character.
Target String, S': xelpame
Now it is your task to implement the encoding and decoding process. Notice
that you have to know the initial character of S to decode.
This problem contains multiple tests. Each test starts with a word "encode" or "decode", followed by the string to be encoded or decoded. The string does not contain any space character. The length of the string will not exceed 100. The last character of the string to be decoded is the initial character of the original string and should not be countered in the target string itself.
One line for each test, containing the encoded or decoded string.
Author: XU, Chuan
Source: ZOJ Monthly, December 2002