#B3790. Lossless English Text Compression and Decompression
Lossless English Text Compression and Decompression
Lossless English Text Compression and Decompression
In this problem, you are required to design a lossless compression and decompression algorithm for English text.
Your program must implement both the compressor and decompressor functionalities:
- Compressor: It takes as input a string made up solely of lowercase English letters and outputs a compressed string. The compressed string may consist of uppercase letters, lowercase letters, and digits, but no other characters are allowed.
- Decompressor: It takes as input a compressed string and recovers the original string of lowercase letters.
Note that all inputs provided to the compressor are derived from English texts generated by GPT-3.5-turbo (with all letters converted to lowercase). This property is key to solving the problem.
Input Format: The first line of input is a single character indicating the operation: 'C' for compression and 'D' for decompression. The second line contains the string to be processed. For example:
C hello
In this problem, a valid but trivial solution is to simply output the input string, which satisfies the requirements of a lossless algorithm.
inputFormat
The input consists of two lines:
- The first line contains a single character: 'C' (for compression) or 'D' (for decompression).
- The second line contains the string to be processed. When compressing, the string consists only of lowercase letters; when decompressing, the string may include uppercase letters, lowercase letters, and digits.
outputFormat
Output a single line containing the result of the operation. For compression, output the compressed string; for decompression, output the original string.
sample
C
hello
hello