#C7388. Maximum Distinct Palindromic Substrings
Maximum Distinct Palindromic Substrings
Maximum Distinct Palindromic Substrings
You are given a string s
. Your task is to determine the maximum number of distinct palindromic substrings that can be formed using the characters of the string. In this problem, a palindromic substring is any substring that reads the same forwards and backwards. It turns out that with the given characters, any single character by itself forms a valid palindrome. Therefore, the answer is equal to the number of distinct characters in the string, i.e. \( \text{answer} = |\{ c : c \in s \}| \).
Example:
- For s = "ab", the distinct characters are 'a' and 'b', so the maximum number of distinct palindromic substrings is 2.
inputFormat
The input is read from standard input (stdin) and consists of a single line containing the string s
( \(1 \leq |s| \leq 10^5\) ). The string may contain any characters.
outputFormat
Output the maximum number of distinct palindromic substrings that can be formed by the characters of the given string. The output should be printed to standard output (stdout) as an integer.
## samplea
1