#abc381c. C - 11/22 Substring

C - 11/22 Substring

当前没有测试数据。

Score : 300300 points

问题陈述

这个问题中11/22字符串的定义与问题A和E中的定义相同。

如果一个字符串TT满足以下所有条件,则称其为11/22字符串

  • T|T|是奇数。这里,T|T|表示TT的长度。
  • 第1个到第(T+121)(\frac{|T|+1}{2} - 1)个字符都是1
  • (T+12)(\frac{|T|+1}{2})个字符是/
  • (T+12+1)(\frac{|T|+1}{2} + 1)个到第T|T|个字符都是2

例如,11/22111/222/是11/22字符串,但11221/2211/222222/11//2/2/211不是。

你给定了一个由12/组成的长度为NN的字符串SS,其中SS至少包含一个/。 找出SS中一个(连续的)子串作为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 TT is called an 11/22 string when it satisfies all of the following conditions:

  • T|T| is odd. Here, T|T| denotes the length of TT.
  • The 11-st through (T+121)(\frac{|T|+1}{2} - 1)-th characters are all 1.
  • The (T+12)(\frac{|T|+1}{2})-th character is /.
  • The (T+12+1)(\frac{|T|+1}{2} + 1)-th through T|T|-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 SS of length NN consisting of 1, 2, and /, where SS contains at least one /.
Find the maximum length of a (contiguous) substring of SS that is an 11/22 string.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • SS is a string of length NN consisting of 1, 2, and /.
  • SS contains at least one /.

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print the maximum length of a (contiguous) substring of SS that is an 11/22 string.

Sample Input 1

8
211/2212

Sample Output 1

5

The substring from the 22-nd to 66-th character of SS is 11/22, which is an 11/22 string. Among all substrings of SS that are 11/22 strings, this is the longest. Therefore, the answer is 55.

Sample Input 2

5
22/11

Sample Output 2

1

Sample Input 3

22
/1211/2///2111/2222/11

Sample Output 3

7