#C5422. Maximum Characters Removed via Palindromic Substrings
Maximum Characters Removed via Palindromic Substrings
Maximum Characters Removed via Palindromic Substrings
You are given a string s
of length n. In each move, you may remove any palindromic substring of s
. Since a single character is considered a palindrome, it is always possible to remove the entire string by removing one character at a time. Your task is to compute the maximum number of characters that can be removed from the string, which, as it turns out, is always n.
Formally, given an integer n
and a string s
of length n
, output n
.
Note: Even if the string is not a palindrome or does not have long palindromic substrings, every single character is a palindrome in itself.
inputFormat
The input consists of two lines. The first line contains a single integer n
representing the length of the string. The second line contains the string s
of length n
.
outputFormat
Output a single integer, which is the maximum number of characters that can be removed from the string by repeatedly removing palindromic substrings.
## sample1
a
1