题目描述
Problem Description
Define a word as a sequence of characters starting with an uppercase letter followed by one or more lowercase letters, with a length greater than 1, such as Ab, Abc, Abcd, and Abcde, but not ab, A, AB, ABc, or AbC.
Define a word sequence as a string containing more than one word, with exactly one space between each pair of words, such as International Business Machines.
Given multiple lines of text, if a word sequence is encountered, it should be abbreviated. The abbreviation is formed by taking the first uppercase letter of each word, followed by a space, an opening parenthesis, the full sequence, and a closing parenthesis. For example, International Business Machines can be abbreviated as IBM (International Business Machines).
Input Format
Multiple lines (up to 1000 lines) of strings consisting of uppercase and lowercase letters, punctuation, and spaces (each line contains no more than 120 characters).
Output Format
The text with each word sequence abbreviated, if applicable.
Sample Input and Output
Input Sample #1
This is ACM North Eastern European Regional Contest,
sponsored by International Business Machines.
The. Best. Contest. Ever.
A Great Opportunity for all contestants.
Output Sample #1
This is ACM NEERC (North Eastern European Regional Contest),
sponsored by IBM (International Business Machines).
The. Best. Contest. Ever.
A GO (Great Opportunity) for all contestants.
Input Sample #2
ab Ab A Abc AB Abcd ABc Abcde AbC
Output Sample #2
ab Ab A Abc AB Abcd ABc Abcde AbC
Input Sample #3
Oh No Extra Spaces.And,Punctuation Ruin Everything
Output Sample #3
Oh No ES (Extra Spaces).And,PRE (Punctuation Ruin Everything)
Notes
Time limit: 1 second, Memory limit: 512 MB.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分