#P14771. [ICPC 2024 Seoul R] Palindromic Length
[ICPC 2024 Seoul R] Palindromic Length
题目描述
A string is called a palindrome if it is read the same forward and backward. Palindromes are useful factors for measuring the complexity of strings like the asymmetry of the strings. The asymmetry of a string of length can be measured by its palindromic length, , which is the minimum number of palindromic substrings into which can be partitioned. More precisely, is the minimum number () such that there exist palindromic substrings whose concatenation becomes . To make it easier to distinguish, we denote a partition of into as .
For example, a string can be partitioned into two palindromic substrings as , that is the minimum, so . A string cannot be partitioned into two palindromic substrings, but it can be partitioned into three palindromic substrings, or , so . For , because is a palindrome. for .
Given a non-empty string of English lowercase letters, write a program to output .
输入格式
Your program is to read from standard input. The input starts with a line containing a positive integer (), where is the number of letters of a string. The next line contains a string of English lowercase letters. Note that the string contains no space between the letters.
输出格式
Your program is to write to standard output. Print exactly one line. The line should contain a positive integer which is the palindromic length of the input string .
6
abaaca
2
5
acaba
3
5
abcde
5
5
radar
1