logo AlgoBeat OnlineJudge
登录 注册

#207481. [ICPC 2020 WF] Gene Folding

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

题目描述

ICPC2020 WF D


International Cell Processing Company (ICPC) is a world leader in the analysis of genetic sequences. A genetic sequence is a sequence of nucleotides, which in this problem is represented by a string containing only the letters , , , and in some combination, each letter representing a single nucleotide (denine, ytosine, uanine, and hymine, respectively).

One of the key discoveries made by ICPC is that through a process called Genetically Optimized Organic Folding (GOOF), they can take a genetic sequence and transform it into a simpler one, while preserving many of the properties of the sequence that ICPC wants to analyze.

A single application of GOOF works as follows. Find a point between two adjacent nucleotides in the nucleotide sequence, such that the sequence reads the same from that point in both directions, up until the nearer end of the sequence. For instance, in the sequence , there are two such points: and . Then pick one of these points (say, the first one), and fold the genetic sequence at that point, merging the identical nucleotides (so, in this case the and would become merged, and the resulting sequence would be or ).

Through repeated application of GOOF, a nucleotide can potentially be made much shorter. However, manually searching for the appropriate folding points is very time-consuming. ICPC reached out to you to write a program that would automate the process of finding the folding points and choosing them so as to obtain the shortest possible genetic sequence from a given input sequence.

输入格式

The input contains a single string representing the nucleotide sequence to be analyzed. The string consists of characters , , , and only. The length of is between and , inclusive.

输出格式

Output the smallest possible length of a sequence obtained from the input by applying GOOF zero or more times.

样例

样例输入 1

ATTACC

样例输出 1

3

样例输入 2

AAAAGAATTAA

样例输出 2

5