report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Color ribbon - FlandreOJ: Flandre Online Judge

Color ribbon

Time limit: 1000 ms
Memory limit: 256 MB
Given a ribbon of length $n$. You can paint a continuous segment on the ribbon with one of 26 colors corresponding to lowercase letters. Initially, the ribbon has no color. Find the way to use the fewest number of painting operations so that the ribbon has the color pattern corresponding to the string $S$. ### Input - A single line containing the string $S$ consisting only of lowercase letters of length $n$. ### Output - Output an integer representing the minimum number of painting operations. ### Constraints - $1 \le n \le 1000$. ### Example Input: ``` abcba ``` Output: ``` 3 ``` Explanation: - The first painting colors `a` from position $1$ to $5$: `aaaaa`. - The second painting colors `b` from position $2$ to $4$: `abbba`. - The third painting colors `c` at position $3$: `abcba`.
Introduction to Dynamic Programming (Part two)
Sake game
Coins
Coins 2
Game on array
Longest increasing subsequence 2
Convolution
Regular bracket sequence
Faulty addition
Weird bank
Delete operation
Palindromize
Color ribbon
Unique subsequences
Unique subsequences 2
Cow exhibition
Knapsack 3
Compressing array
Regular bracket sequence 2
Maximum path 3
Concating substring
Soil
Stacking boxes
String transformation
Palindromic quadruple
Finding teammates
Topic
Dynamic Programming
Rating 1400
Solution (0) Solution