PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CT00048. Đoạn phân biệt (Longest Distinct Segment)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đoạn phân biệt (Longest Distinct Segment)

Longest Distinct Segment

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a string SS consisting of uppercase Latin letters, lowercase Latin letters, and digits. Its positions are numbered from 11 to ∣S∣|S|. A contiguous substring SLSL+1…SRS_LS_{L+1}\ldots S_R is distinct if no character occurs more than once in it.

Find a longest distinct substring. If several have maximum length, choose the one with the smallest starting position LL.

Input

One line contains the string SS, without spaces.

Output

Print three space-separated integers D,L,RD,L,R: the maximum length and the endpoints of the chosen substring.

Subtasks

  • Subtask 1 (30 points): 1≤∣S∣≤20001\le|S|\le2000.
  • Subtask 2 (30 points): 1≤∣S∣≤1051\le|S|\le10^5.
  • Subtask 3 (40 points): 1≤∣S∣≤1061\le|S|\le10^6.

Examples

Example 1

Input

abcaef

Output

5 2 6

Explanation

Positions 1..31..3 give abc. At position 44, a repeats the character at position 11, so the longest valid substring ending at 44 starts at 22. Appending e and f gives bcaef at [2,6][2,6], length 55. The whole string repeats a, so length 66 is impossible.

Example 2

Input

aaaa

Output

1 1 1

Explanation

Every character is a, so any substring of length at least two contains a repetition. Among the four substrings of length one, choose the earliest: L=R=1L=R=1.

Example 3

Input

abcabcbb

Output

3 1 3

Explanation

Valid length-three substrings include abc, bca, and cab. Every length-four substring repeats a character. The earliest maximum-length substring is abc at [1,3][1,3].