306672: CF1234F. Yet Another Substring Reverse
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Yet Another Substring Reverse
题意翻译
给你一个字符串$S$,你可以翻转一次$S$的任意一个子串。 问翻转后$S$的子串中各个字符都不相同的最长子串长度。 $|S|\le10^6,|$字符集$|\le20$题目描述
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 $ s_l s_{l + 1} \dots s_r $ . 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 $ s_l s_{l + 1} \dots s_r $ becomes $ s_r s_{r - 1} \dots s_l $ ). 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 $ 10^6 $ 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