#P4170. [CQOI2007] 涂色
[CQOI2007] 涂色
Description
Suppose you have a wooden board of length , initially unpainted. You want to paint its unit segments red, green, blue, green, and red, respectively, represented by a length- string: .
Each time, you may paint a consecutive segment of the board with a given color, and later paint covers earlier paint. For example, first paint , then paint , and finally paint to reach the target.
Use as few painting operations as possible to reach the target.
Input Format
The input contains a single line with a string of length , which is the painting target. Every character is an uppercase letter; different letters denote different colors, and the same letters denote the same color.
Output Format
Output a single line with one number: the minimum number of painting operations.
AAAAA
1
RGBGR
3
Hint
of the testdata satisfies .
of the testdata satisfies .
Translated by ChatGPT 5
京公网安备 11011102002149号