Logo
(追記) (追記ここまで)

25227번 - Cram 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB86444164.062%

문제

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

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 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 $s,ドル with 1ドル \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.

제한

예제 입력 1

abcabcabcabc

예제 출력 1

6

예제 입력 2

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

예제 출력 2

4

예제 입력 3

A man a plan a canal Panama

예제 출력 3

25

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2022 C번

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 1: Welcome Contest B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /