atcoder#ABC299C. [ABC299C] Dango
[ABC299C] Dango
Score : points
Problem Statement
For a positive integer , a level- dango string is a string that satisfies the following conditions.
- It is a string of length consisting of
o
and-
. - Exactly one of the first character and the last character is
-
, and the other characters areo
.
For instance, ooo-
is a level- dango string, but none of -ooo-
, oo
, and o-oo-
is a dango string (more precisely, none of them is a level- dango string for any positive integer ).
You are given a string of length consisting of the two characters o
and -
.
Find the greatest positive integer that satisfies the following condition.
- There is a contiguous substring of that is a level- dango string.
If there is no such integer, print -1
.
Constraints
- is a string of length consisting of
o
and-
.
Input
The input is given from Standard Input in the following format:
Output
Print the greatest positive integer such that contains a level- dango string, or -1
if there is no such integer.
10
o-oooo---o
4
For instance, the substring oooo-
corresponding to the -rd through -th characters of is a level- dango string.
No substring of is a level- dango string or above, so you should print .
1
-
-1
Only the empty string and -
are the substrings of .
They are not dango strings, so you should print -1
.
30
-o-o-oooo-oo-o-ooooooo--oooo-o
7