#P11305. Longest Substring Deletion Interval

    ID: 13381 Type: Default 1000ms 256MiB

Longest Substring Deletion Interval

Longest Substring Deletion Interval

Given a string \(s\). Define \(s(l,r)\) as the substring consisting of the characters from the \(l\)th to \(r\)th position (1-indexed) in \(s\), and \(t(l,r)\) as the string obtained by removing the characters from the \(l\)th to \(r\)th position from \(s\). Find the longest interval \([l, r]\) such that \(s(l,r)\) appears as a substring in \(t(l,r)\). If there are multiple answers, you may output any. If no such interval exists, output "0 0".

Note: All indices are 1-indexed. A substring is a contiguous part of a string.

Example: For \(s = \texttt{aba}\), one valid answer is \(l=1, r=1\) since \(s(1,1)=a\) and \(t(1,1)=ba\) which contains \(a\) as a substring.

inputFormat

The input consists of a single line containing the string \(s\). The string may contain only printable characters and its length is at least 1.

outputFormat

Output two integers \(l\) and \(r\) separated by a space, representing the 1-indexed boundaries of the longest interval satisfying the condition. If no valid interval exists, output "0 0".

sample

aba
1 1