아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Cram

시간 제한1초메모리 제한1024 MB

요약
문자열이 주어질 때, 각 문자는 1바이트, 앞쪽 b개 문자를 복사하는 역참조 [a,b]는 3바이트일 때 최소 인코딩 비용을 구합니다.
난이도

보통10점 중 7점

유형
동적 계획법, 문자열 매칭, 문자열
정답자
아직 제출이 없습니다

문제

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

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

abcabcabcabc

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

abc[3,9]

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

Output the minimum cost to encode the text passage.

입력

The single line of input contains a string ss, with 1≤∣s∣≤1051 \le |s| \le 10^5. This line of text consists of upper-case 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.

예제3

  1. 예제 1

    입력
    abcabcabcabc
    
    예상 출력
    6
    
  2. 예제 2

    입력
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    
    예상 출력
    4
    
  3. 예제 3

    입력
    A man a plan a canal Panama
    
    예상 출력
    25