cod
We can use an algorithm
that identifies repeating subsequences in a text in order to encode the text.
The basic idea of the algorithm is to replace a subsequence of the text with
a reference in the form of &startPos-endPos,
meaning that the subsequence being replaced is identical with the subsequence
from the initial text that starts from position startPos
and ends with position endPos.
Warning! the specified positions refer to the original text, not to the encoded
text.
E.g. text ABCDEFG ABCDEFG can be coded as &8-14 ABCDEFG.
Positions in the initial row are numbered starting with 0.
Task
Write a program that reads a text encoded like above and determines the original text.
Input Data
Input file cod.in contains a single line with a sequence of characters, representing the encoded text.
Output Data
Output file cod.out will contain a single line with the original text whose encoding is in the input file.
Constraints
Example
cod.in |
cod.out | cod.in |
cod.out |
ABCDEFG &0-6 |
ABCDEFG ABCDEFG | ABA&13-14CC&10-11&17-18ACC&13-14AC&0-1 | ABACCCCAACAACCCCACAB
|
Time limit: 0.1 seconds/test
prof. Popescu Carmen
"Gheorghe Lazar" Sibiu National High School
carmen_cngl@yahoo.com