#abc299c. C - Dango

C - Dango

Score : 300300 points

问题描述

对于一个正整数 LL,级别为LL 的团子串是一个满足以下条件的字符串。

  • 它是由 o- 组成的长度为 L+1L+1 的字符串。
  • 第一个字符和最后一个字符中恰好有一个是 -,其余 LL 个字符均为 o

例如,ooo- 是一个级别为3的团子串,但 -ooo-ooo-oo- 均不是团子串(更准确地说,它们都不是任何正整数 LL 级别的团子串)。

给定一个由字符 o- 组成的长度为 NN 的字符串 SS。找出满足以下条件的最大正整数 XX

  • 字符串 SS 中存在一个连续子串,它是级别为 XX 的团子串。

如果没有这样的整数,请输出 -1

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

For a positive integer LL, a level-LL dango string is a string that satisfies the following conditions.

  • It is a string of length L+1L+1 consisting of o and -.
  • Exactly one of the first character and the last character is -, and the other LL characters are o.

For instance, ooo- is a level-33 dango string, but none of -ooo-, oo, and o-oo- is a dango string (more precisely, none of them is a level-LL dango string for any positive integer LL).

You are given a string SS of length NN consisting of the two characters o and -. Find the greatest positive integer XX that satisfies the following condition.

  • There is a contiguous substring of SS that is a level-XX dango string.

If there is no such integer, print -1.

Constraints

  • 1N2×1051\leq N\leq 2\times10^5
  • SS is a string of length NN consisting of o and -.

Input

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

NN

SS

Output

Print the greatest positive integer XX such that SS contains a level-XX dango string, or -1 if there is no such integer.

Sample Input 1

10
o-oooo---o

Sample Output 1

4

For instance, the substring oooo- corresponding to the 33-rd through 77-th characters of SS is a level-44 dango string. No substring of SS is a level-55 dango string or above, so you should print 44.

Sample Input 2

1
-

Sample Output 2

-1

Only the empty string and - are the substrings of SS. They are not dango strings, so you should print -1.

Sample Input 3

30
-o-o-oooo-oo-o-ooooooo--oooo-o

Sample Output 3

7

update @ 2024/3/10 12:24:20