本站作为LDUOnlineJudge的测试版本进行演示,官方网站请访问http://icpc.ldu.edu.cn
[Hidden]

1224. D. Cell Phone Contacts


Description

Modern cellular phones have a small chip, called a SIM card, that allows the phone to interface with the carrier's network. SIM cards also have a small amount of memory onboard where the user can store data, such as names, phone numbers, and e-mail addresses. A common problem with SIM card memory is that it cannot group several numbers under the same name, as most cell phones can. This poses a problem when the user wishes to switch phones. The easiest way to transfer contacts is to copy them to the SIM card from the old phone, and then copy them back from the SIM card to the new phone. However, if the user has multiple phone numbers and/or e- mail addresses for a given name, the contact information will be broken up, with multiple entries of the same name, each associated with a different phone number or e-mail address.

Obviously, the user of the new phone would like for his or her contact data to be organized, with each contact's name listed only once, and the various phone numbers and e-mail addresses for that contact organized under that single entry. You are to write a program to help with this.

The Problem:

Given the contact data from a SIM card, consisting of pairs of names and email addresses or names and phone numbers, generate organized input data for the new cell phone. The new cell phone has a strict data format that must be followed precisely (the format is described in The Output section below).

Input

There will be multiple contact lists (test cases) to process. The first line of each contact list contains a single integer, n(1n100), indicating the number of contact data entries on the SIM card. On each of the next nn lines will be a name, followed by either a phone number or an e-mail address. Names consist of exactly two strings of upper- and lower-case alphabetic characters (the first name followed by the last name). Each first (last) name is at least one character and at most 20 characters. There will be exactly one space between the first and last names in input, and one space between the last name and the phone number or e-mail address. A phone number will consist of exactly 10 digits (no hyphens). An e-mail address will consist of a string of letters and/or numbers separated by exactly one at ('@') sign, and at least one dot ('.'). No input line will exceed 80 characters. There will be no leading or trailing whitespace on any line.

End of input is indicated by a value of 0 for n. This case should not be processed.

Output

For each data set, print the heading "Contact list #d:" where dd is the set number in the input (starting with 1). Then, for each unique contact (by name) in the set, output a contact entry. Note that case is significant, so "John DOE" is a different contact from "John Doe". Contact entries must be output in the following format:

<Contact Name>

Phone:

<Phone Number 1>

<Phone Number 2>

...

<Phone Number p>

E-Mail:

<E-Mail Address 1>

<E-Mail Address 2>

...

<E-Mail Address q>

###

Phone numbers should be printed in the format "(123)456-7890". E-mail addresses should be printed exactly as input. Contact entries should be output in ascending ASCII order by last name, then first name. Within each contact, phone numbers should be output in numerical order, and e-mail addresses should be output in ascending ASCII order. There must be no leading or trailing spaces in the output. (Note that the built-in string comparison functions do compare strings in ASCII order.)

Leave a blank line after the output for each data set. Follow the format illustrated in Sample Output.

Samples

Input Copy
6
John Doe 4071234567
Bill Smith bsmith@somewhere.com
Bill Smith 1231231234
John Doe John.Doe@my.house.net
John Doe John.Doe@work.com
Bill Smith 1234567890
2
Bone Head 1231231234
Air Head airhead@my.house.net
0
Output
Contact list #1:
John Doe
Phone:
(407)123-4567
E-Mail:
John.Doe@my.house.net
John.Doe@work.com
###
Bill Smith
Phone:
(123)123-1234
(123)456-7890
E-Mail:
bsmith@somewhere.com
###

Contact list #2:
Air Head
Phone:
E-Mail:
airhead@my.house.net
###
Bone Head
Phone:
(123)123-1234
E-Mail:
###

Source

UCF Practice 2013
Problem Information

Time Limit: 1000MS (C/C++,Others×2)
Memory Limit: 256MB (C/C++,Others×2)
Special Judge: No
AC/Submit: 1 / 1
Tags:
Contests involved

1026. UCF 2013 Practice
My history solutions

You didn't submit any solution!
Submit your solution

Login Register