12304 - Huffman Compression
|
Time |
Memory |
| Case 1 |
1 sec |
32 MB |
| Case 2 |
1 sec |
32 MB |
| Case 3 |
1 sec |
32 MB |
| Case 4 |
1 sec |
32 MB |
| Case 5 |
1 sec |
32 MB |
| Case 6 |
1 sec |
32 MB |
| Case 7 |
1 sec |
32 MB |
| Case 8 |
1 sec |
32 MB |
| Case 9 |
1 sec |
32 MB |
| Case 10 |
1 sec |
32 MB |
Description
Given
Task
- Calculate character distribution in the text, do a stable sort
- Build a Huffman tree
- Encode the word given at the first line based on the Huffman tree
Input
- The first line of input contains a single positive integer n (number of lines of the text) and a word, separated by a comma, followed by newline
- The next n lines contains zero or more characters(with whitespace), they all end in newlines. This will be the text.


Output

Tags