QOJ.ac

QOJ

时间限制: 4.0 s 内存限制: 512 MB 总分: 100

#17614. Deletion

统计

Let $w$ be a given word — a sequence of $n$ lowercase English letters. For given positions, i.e., natural numbers $a$ and $b$ such that $1 \le a \le b \le n$, we define the substring $w_{a,b}$ as the word obtained by taking all characters in order from the $a$-th position to the $b$-th position in the word $w$. We also define the remainder $o_{a,b}$ as the word obtained when we delete all characters from the $a$-th position to the $b$-th position in the word $w$.

Find the length of the longest substring $w_{a,b}$ such that the remainder $o_{a,b}$ also contains $w_{a,b}$ as a substring.

Input

The first line contains the given word $w$ — a sequence of lowercase English letters.

Output

Print the required maximum possible length.

Subtasks

Let $n$ be the length of the given word.

Subtask Points Constraints
1 16 $1 \le n \le 400$
2 24 $401 \le n \le 5\,000$
3 60 $5001 \le n \le 100\,000$

Examples

Input 1

abcxyzabc

Output 1

3

Input 2

bbcdbcbbcbadadda

Output 2

5

Note

Explanation of the second example: bbcdbcbbcbadadda $\to$ bbcdbcbadda. In this case, the substring bbcdb (length 5) is removed, and the remaining word bbcdbcbadda contains bbcdb as a substring.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.