#abc381c. C - 11/22 Substring
C - 11/22 Substring
当前没有测试数据。
Score : points
问题陈述
这个问题中11/22字符串的定义与问题A和E中的定义相同。
如果一个字符串满足以下所有条件,则称其为11/22字符串:
- 是奇数。这里,表示的长度。
- 第1个到第个字符都是
1。 - 第个字符是
/。 - 第个到第个字符都是
2。
例如,11/22、111/222和/是11/22字符串,但1122、1/22、11/2222、22/11和//2/2/211不是。
你给定了一个由1、2和/组成的长度为的字符串,其中至少包含一个/。
找出中一个(连续的)子串作为11/22字符串的最大长度。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
The definition of an 11/22 string in this problem is the same as in Problems A and E.
A string is called an 11/22 string when it satisfies all of the following conditions:
- is odd. Here, denotes the length of .
- The -st through -th characters are all
1. - The -th character is
/. - The -th through -th characters are all
2.
For example, 11/22, 111/222, and / are 11/22 strings, but 1122, 1/22, 11/2222, 22/11, and //2/2/211 are not.
You are given a string of length consisting of 1, 2, and /, where contains at least one /.
Find the maximum length of a (contiguous) substring of that is an 11/22 string.
Constraints
- is a string of length consisting of
1,2, and/. - contains at least one
/.
Input
The input is given from Standard Input in the following format:
Output
Print the maximum length of a (contiguous) substring of that is an 11/22 string.
Sample Input 1
8
211/2212
Sample Output 1
5
The substring from the -nd to -th character of is 11/22, which is an 11/22 string. Among all substrings of that are 11/22 strings, this is the longest. Therefore, the answer is .
Sample Input 2
5
22/11
Sample Output 2
1
Sample Input 3
22
/1211/2///2111/2222/11
Sample Output 3
7