Decode
Data travels through computer networks as a sequence of bits. In order to know how to read received message, the recipient has to have information about the way characters are recorded. One possible way is to choose a fixed number of bits, say K, and to assign each character a number between 0 and 2^{K - 1}. Advantage of using such a method is that recipient knows that every number is represented with exactly K bits and so they can easily determine all the characters. But this method has a drawback - even small numbers require K bits and so the process of transmission lasts longer than it might. That's why data compression is used.
One way to compress data is allowing character records to have different bit lengths. Characters appearing more often in the message get assigned shorter numbers and those which appear rarely get assigned longer numbers. It is necessary that each character gets assigned a record which is NOT a prefix of some other character's record (otherwise one might not know whether to stop reading bits and print the character or continue and print some other character).
Your task is to write a decoder of a message compressed in the way described above, provided you've been given a code table.
5
A 0000
! 0001
c 001
D 01
e 1
00000001001100101Output
A!cecD 5
a 110
b 111
c 00
. 01
e 10
11010011110011010Output
ae.bcae Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.