#C14379. Longest Word Finder

    ID: 44021 Type: Default 1000ms 256MiB

Longest Word Finder

Longest Word Finder

Given a sentence, your task is to find the longest word in it. A word is defined as a sequence of alphanumeric characters and underscores (i.e. matching the regular expression \(\texttt{\textbackslash\b\w+\b}\)). If there is a tie, the word which appears first in the sentence should be returned.

Special cases:

  • If the input string is empty, output "The input string is empty.".
  • If the sentence contains no valid words (for example, if it only has punctuation), output "The input string contains no valid words.".

You are required to read the input from the standard input (stdin) and output the answer to the standard output (stdout).

inputFormat

The input consists of a single line, which is the sentence from which the longest word is to be found.

outputFormat

Output a single line containing the longest word. If the input is empty or there are no valid words, output the corresponding message.

## sample
hello world, this is a fantastic day!
fantastic