7005.Empty String

Time Limit: 1s Memory Limit: 512MB

You are given a string consisting of $n$ characters between a and z.

On each turn, you may remove any two adjacent characters that are equal. Your goal is to construct an empty string by removing all the characters.

In how many ways can you do this?

Input Format(From the terminal/stdin)

The only input line has a string of length $n$ .

  • $1 \le n \le 500$

Output Format(To the terminal/stdout)

Print one integer: the number of ways modulo $10^9+7$ .

Sample Input

Copy
aabccb
      \n

Sample Output

Copy
3
 \n
Source: CSES, Counting Problems, 1080

Submit

请先 登录

© 2025 FAQs