#K57747. Longest Unique Substring

    ID: 30489 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

Given a string s, your task is to find the longest substring that contains only distinct characters. In other words, the substring must not contain any repeated characters.

If there are multiple substrings with the same maximum length, output the one that appears first. The answer should be presented as two values: the length of the substring and the substring itself.

You can represent the chosen substring as \( s[i \ldots j] \) with its length given by \( j-i+1 \).

inputFormat

The input consists of a single line containing the string s. The string can be empty.

outputFormat

Output two items in one line: the length of the longest substring with distinct characters, followed by a space and then the substring itself. If the input string is empty, output 0 only.

## sample
abcabcbb
3 abc