W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
We consider strings consisting of lowercase letters of the English alphabet in this problem. An initial fragment of a given string is called its prefix. A final (terminal) fragment of a given string is called its suffix. In particular, the empty string is both a prefix and a suffix of any string. Two strings are cyclically equivalent if one of them can be obtained from another by moving its certain suffix from the end of the string to its beginning. For example, the strings and are cyclically equivalent, whereas the strings and are not. In particular, every string is cyclically equivalent to itself.
A string consisting of letters is given. We are looking for its prefix and suffix of equal length such that:
The first line of the standard input contains a single integer () denoting the length of the string . The second line of input contains the string itself, consisting of lowercase letters of the English alphabet.
In tests worth 30% of the points the condition holds in addition.
In tests worth 50% of the points the condition holds in addition.
Your program should print a single integer in the first and only line of the standard output, namely the common length of the prefix and the suffix that we are looking for.
For the input data:
15 ababbabababbaab
the correct result is:
6
Task author: Jacek Tomasiewicz.