#K44712. Longest Word Finder in a Manuscript

    ID: 27593 Type: Default 1000ms 256MiB

Longest Word Finder in a Manuscript

Longest Word Finder in a Manuscript

You are given a manuscript string that may include letters, digits, punctuation, and white spaces. Your task is to extract all contiguous sequences of lowercase letters (i.e. words) from the string. Determine the maximum length (L) among these words, and then output (L) followed by those words that have length (L) in the order they appear in the manuscript. If no valid word is found, output only 0. For example, for the input the_quick_brown_fox_jumps_over_the_lazy_dog, the words with maximum length 5 are quick, brown, and jumps.

inputFormat

The input is provided via standard input (stdin) as a single line containing the manuscript string. The string may contain spaces and various non-alphabet characters.

outputFormat

Print the integer (L), the length of the longest word. If (L > 0), then on a new line print the words of length (L) in the order they appear, separated by a single space. If no word is found, output only 0.## sample

the_quick_brown_fox_jumps_over_the_lazy_dog
5

quick brown jumps

</p>