#P7180. [BalticOI 2004] Repeats (Day2)

[BalticOI 2004] Repeats (Day2)

Description

If a string ss satisfies:

  • For a pair of numbers (k,l) (k1,l1)(k,l)~(k\ge 1,l\ge 1).
  • ss is formed by concatenating kk copies of a string tt of length ll.

Then ss is called a (k,l) - repeat(k,l)\text{ - repeat} string.

For example, s=abaabaabaabas=\tt abaabaabaaba is a (4,3) - repeat(4,3)\text{ - repeat} string with t=abat=\tt aba.

Given a string uu (containing only characters a\texttt a and b\texttt b), you need to find a contiguous substring of uu that is a (k,l) - repeat(k,l)\text{ - repeat} string, such that kk is as large as possible.

For example, u=babbabaabaabaababu=\tt babb\underline{abaabaabaaba}b, where the underlined part is a (4,3) - repeat(4,3)\text{ - repeat} string, and in this case kk is maximized.

Input Format

The first line contains an integer nn, representing the length of uu.

The next nn lines each contain one character (a\texttt a or b\texttt b), describing the string.

Output Format

The first line contains a number kk.

The second line contains a number ll.

The third line contains a number pp, representing the starting position of this (k,l) - repeat(k,l)\text{ - repeat} substring (positions start from 11).

If there are multiple valid answers, output any one of them.

17
b
a
b
b
a
b
a
a
b
a
a
b
a
a
b
a
b 
4
3
5

Hint

Constraints

For 100%100\% of the testdata, 1n5×1041\le n\le 5\times 10^{4}, ui{a,b}u_i\in\{\tt a,b\}.

Notes

Translated from BalticOI 2004 Day2 A Repeats.

Special thanks to

https://www.luogu.com.cn/user/764746
SPJ.

Translated by ChatGPT 5