logo AlgoBeat OnlineJudge
登录 注册

#216113. [ICPC 2022 NAC] Cram

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You want to compress a given text passage using backreferences. A backreference is a pair of numbers indicating that the next characters of the string are the same as the characters starting characters back from the current position. The two strings may overlap, i.e., may be smaller than .

Each backreference costs three bytes to encode, regardless of the number of characters represented by the backreference. String characters cost one byte each to encode.

For instance, the string

has 12 characters. But the last nine can be represented as a backreference to the first nine, as follows:

The total cost of this encoded string is 6: 3 bytes for the string abc, and 3 bytes for the backreference.

Output the minimum cost to encode the text passage.

输入格式

The single line of input contains a string , with . This line of text consists of uppercase letters ('A'–'Z'), lower-case letters ('a'–'z'), and spaces. There will not be any spaces at the beginning or end of the line, and no space character will be adjacent to another space character.

输出格式

Output a single integer, which is the minimum cost to represent the input string using backreferences.

样例

样例输入 1

abcabcabcabc

样例输出 1

6

样例输入 2

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

样例输出 2

4

样例输入 3

A man a plan a canal Panama

样例输出 3

25