#CT0000068. Tách từ và thống kê cực đại (Word Splitting and Maximum-Length Statistics)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Tách từ và thống kê cực đại (Word Splitting and Maximum-Length Statistics)
Word Splitting and Maximum-Length Statistics
Problem Statement
A word is a nonempty consecutive sequence of English letters (A–Z, a–z) or digits (0–9). Words are separated by one or more ASCII spaces. Leading and trailing spaces do not create empty words.
Given a string , extract all words in their original order. Determine the number of words, the maximum word length, and the number of words achieving that maximum.
Your solution must also handle consecutive spaces, leading/trailing spaces, and very long words.
Input
- One line contains a string with at least one word. It may have leading or trailing spaces.
Output
- The first line contains , , : the word count, maximum word length, and number of words with length .
- On the next lines, print word and its length separated by one space. Preserve word order.
Subtasks
-
The string contains only English letters, digits and ASCII spaces.
-
Subtask 1 (25%): ; exactly one separating space, with no leading/trailing spaces.
-
Subtask 2 (35%): ; repeated spaces allowed; each word is at most characters long.
-
Subtask 3 (40%): ; no additional restrictions.
Examples
Example 1
Input
Tin hoc tre
Output
3 3 3
Tin 3
hoc 3
tre 3
Explanation
Ignoring leading, trailing, and repeated separating spaces leaves exactly three words: Tin, hoc, and tre. Each has length , giving , , and . Print them in their original order with their lengths.
Example 2
Input
a bbbbbbbbbbbb C9
Output
3 12 1
a 1
bbbbbbbbbbbb 12
C9 2
Explanation
The three words are a, bbbbbbbbbbbb, and C9, with lengths . Only the second word has the maximum length . Therefore print 3 12 1, followed by the three original words and their lengths.
Example 3
Input
ABC123
Output
1 6 1
ABC123 6
Explanation
The entire line ABC123 is one word: all six letters and digits belong to it. Thus , , , and its output row is ABC123 6.