Wednesday, August 18, 2010

UVa 625 Compression

Problem: given a set of 16 reserved words, transcript a program text to the compressed form that replacing reserved words and other identifier words to number labels.

Size: all identifier words is less than 40 characters and there is 2000 different words at most.

Solution: keep a table of identifiers, and replace strings line-by-line.

Note: an input line does not exceed 200 characters. Furthermore, all encoded identifier (including reserved words) are 3 or more characters.

No comments: