String Game
Time limit2sMemory limit1024 MB
Given a string, find the longest substring that has at least two non-overlapping occurrences in the string and print its length.
- Level
Medium6 of 10
- Topics
- String matching, Binary search, Sorting
- Solved
- No attempts yet
Problem
Albert Moiseevich recently updated his iPad to iOS 8.1. Without much thought, he installed a new game that came out only yesterday.
The game is simple. You are given a string made of lowercase Latin letters. Within the time limit, the player must find a substring that has the maximum number of non-overlapping occurrences in . An occurrence of a substring in is a pair with such that the part of from position to position , inclusive, equals . Two occurrences and are non-overlapping if the segments and do not intersect.
The player earns points equal to the length of the found substring. Albert Moiseevich wants to score as many points as possible, so he asks you to find the substring of maximum length that satisfies this condition.
Input
The first and only line contains the string (), made only of lowercase Latin letters.
Output
Print one line with the maximum length of a substring that satisfies the condition.