CF1234F.Yet Another Substring Reverse
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string s consisting only of first 20 lowercase Latin letters ('a', 'b', ..., 't').
Recall that the substring s[l;r] of the string s is the string slsl+1…sr . For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".
You can perform the following operation no more than once: choose some substring s[l;r] and reverse it (i.e. the string slsl+1…sr becomes srsr−1…sl ).
Your goal is to maximize the length of the maximum substring of s consisting of distinct (i.e. unique) characters.
The string consists of distinct characters if no character in this string appears more than once. For example, strings "abcde", "arctg" and "minecraft" consist of distinct characters but strings "codeforces", "abacaba" do not consist of distinct characters.
输入格式
The only line of the input contains one string s consisting of no more than 106 characters 'a', 'b', ..., 't' (first 20 lowercase Latin letters).
输出格式
Print one integer — the maximum possible length of the maximum substring of s consisting of distinct characters after reversing no more than one its substring.
输入输出样例
输入#1
abacaba
输出#1
3
输入#2
abcdecdf
输出#2
6
输入#3
aabbcc
输出#3
3
输入#4
abcdeefc
输出#4
6