Proofs of Algorithm Correctness and Runtime Estimates · Application: Data Compression (Optional)

Lesson 12

Nikolai Chukhin · Alexander S. Kulikov

Programming problem.

Given a non-empty string \(s\) of length at most \(10^{4}\), consisting of lowercase Latin letters, construct an optimal prefix-free code. In the first line, output the number of distinct letters \(k\) in the string and the size of the resulting encoded string. In the next \(k\) lines, print the codes of the letters in the format «letter: code». In the last line, output the encoded string.

1 point
Public samples
Public sample 1
Input
a

Expected output
1 1
a: 0
0