#K81537. Longest Alphabetical Substring

    ID: 35775 Type: Default 1000ms 256MiB

Longest Alphabetical Substring

Longest Alphabetical Substring

Given a string S consisting of English alphabets and commas, your task is to find and output the longest contiguous substring of S that contains only alphabetic characters. In other words, you need to ignore commas in the string. If there exist multiple substrings with the maximum length, output the one that appears first.

The problem requires careful handling of edge cases such as when the string is empty or when it contains no alphabetic characters at all. Use standard input to read the input and standard output to print the result.

Note: All formulas or conditions mentioned in the problem are in LaTeX format. For example, the condition for substring length can be considered as \(\text{length} > 0\).

inputFormat

The input consists of a single line containing the string \(S\) which is made up of uppercase and lowercase English letters and commas.

Input Format:

S

outputFormat

Output the longest contiguous substring of \(S\) that contains only alphabetic characters. If there are multiple substrings of the same maximum length, output the one that appears first. If no such substring exists, output an empty string.

Output Format:

result
## sample
hello,this,is,a,test
hello