atcoder#ABC141E. [ABC141E] Who Says a Pun?
[ABC141E] Who Says a Pun?
Score : points
Problem Statement
Given is a string of length .
Find the maximum length of a non-empty string that occurs twice or more in as contiguous substrings without overlapping.
More formally, find the maximum positive integer such that there exist integers and ( ) that satisfy the following:
If there is no such integer , print .
Constraints
- consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum length of a non-empty string that occurs twice or more in as contiguous substrings without overlapping. If there is no such non-empty string, print instead.
5
ababa
2
The strings satisfying the conditions are: a
, b
, ab
, and ba
. The maximum length among them is , which is the answer.
Note that aba
occurs twice in as contiguous substrings, but there is no pair of integers and mentioned in the statement such that .
2
xy
0
No non-empty string satisfies the conditions.
13
strangeorange
5