#P2470. [SCOI2007] 压缩
[SCOI2007] 压缩
Description
Given a string consisting of lowercase letters, we can compress its repeated information using a simple method. The compressed string may (but does not have to) contain uppercase letters and in addition to lowercase letters, where marks the start of a repeated segment, and repeats the decompressed result starting from the previous (if there is no to the left of the current position, start from the beginning of the string), which is called the buffer string.
can be compressed as . The decompression process is shown below:
| Already decompressed part | Decompression result | Buffer string |
|---|---|---|
Input Format
The input contains a single line with the string to compress, consisting only of lowercase letters, of length .
Output Format
Output a single line: the minimum possible length of the compressed string.
aaaaaaa
5
bcdcdcdcdxcdcdcdcd
12
Hint
In the first example, an answer is . In the second example, an answer is .
Constraints
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号