CF1234F.Yet Another Substring Reverse
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
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.
给你一个字符串 s,它仅由前 20 个小写拉丁字母(即 'a'、'b'、…、't')组成。
回忆一下,字符串 s 的子串 s[l;r] 是指字符串 slsl+1…sr。例如,"codeforces" 的子串包括 "code"、"force"、"f"、"for",但不包括 "coder" 和 "top"。
你可以至多执行一次如下操作:选择某个子串 s[l;r] 并将其反转(即字符串 slsl+1…sr 变为 srsr−1…sl)。
你的目标是最大化字符串 s 中最长的、由互不相同(即唯一)字符组成的子串的长度。
一个字符串由互不相同的字符组成,当且仅当该字符串中每个字符至多出现一次。例如,字符串 "abcde"、"arctg" 和 "minecraft" 由互不相同的字符组成;而字符串 "codeforces"、"abacaba" 则不是。
输入格式
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).
输入仅包含一行,该行有一个字符串 s,由不超过 106 个字符组成,这些字符仅限于 'a', 'b', ..., 't'(前 20 个小写拉丁字母)。
输出格式
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.
输出一个整数——在最多反转 s 的一个子串后,s 中由互不相同字符组成的最长子串的最大可能长度。
输入输出样例
输入#1
abacaba
输出#1
3
输入#2
abcdecdf
输出#2
6
输入#3
aabbcc
输出#3
3
输入#4
abcdeefc
输出#4
6
输入解题思路,AI测评打分。不知道怎么写?