CF898C.Phone Numbers

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya has several phone books, in which he recorded the telephone numbers of his friends. Each of his friends can have one or several phone numbers.

Vasya decided to organize information about the phone numbers of friends. You will be given n strings — all entries from Vasya's phone books. Each entry starts with a friend's name. Then follows the number of phone numbers in the current entry, and then the phone numbers themselves. It is possible that several identical phones are recorded in the same record.

Vasya also believes that if the phone number a is a suffix of the phone number b (that is, the number b ends up with a), and both numbers are written by Vasya as the phone numbers of the same person, then a is recorded without the city code and it should not be taken into account.

The task is to print organized information about the phone numbers of Vasya's friends. It is possible that two different people have the same number. If one person has two numbers x and y, and x is a suffix of y (that is, y ends in x), then you shouldn't print number x. If the number of a friend in the Vasya's phone books is recorded several times in the same format, it is necessary to take it into account exactly once.

Read the examples to understand statement and format of the output better.

瓦西里有几本电话簿,他在其中记录了朋友们的电话号码。每位朋友可能有一个或多个电话号码。

瓦西里决定整理有关朋友们电话号码的信息。你将收到 nn 个字符串——这些是瓦西里所有电话簿中的全部条目。每个条目以朋友的名字开头,接着是该条目中电话号码的个数,然后是这些电话号码本身。同一记录中可能重复出现相同的电话号码。

此外,瓦西里认为:如果电话号码 aa 是电话号码 bb 的后缀(即 bb 以 aa 结尾),且 aa 和 bb 均被瓦西里记录为同一人的电话号码,则 aa 是未带区号的号码,应不予考虑。

你的任务是输出经整理后的瓦西里朋友们的电话号码信息。不同的人可能拥有相同的电话号码。如果某人拥有两个号码 xx 和 yy,且 xx 是 yy 的后缀(即 yy 以 xx 结尾),则不应输出号码 xx。如果某位朋友的某个电话号码在瓦西里的电话簿中以完全相同的形式重复记录多次,则该号码仅需统计一次。

请阅读样例以更清晰地理解题意及输出格式。

输入格式

First line contains the integer n (1 ≤ n ≤ 20) — number of entries in Vasya's phone books.

The following n lines are followed by descriptions of the records in the format described in statement. Names of Vasya's friends are non-empty strings whose length does not exceed 10. They consists only of lowercase English letters. Number of phone numbers in one entry is not less than 1 is not more than 10. The telephone numbers consist of digits only. If you represent a phone number as a string, then its length will be in range from 1 to 10. Phone numbers can contain leading zeros.

第一行包含整数 nn(1≤n≤201 \leq n \leq 20)——表示瓦夏电话簿中的条目数量。

接下来的 nn 行依次为题目描述中所规定的记录格式。瓦夏朋友的名字是非空字符串,长度不超过 10,且仅由小写英文字母组成。每个条目中电话号码的数量不少于 1 且不多于 10。电话号码仅由数字组成。若将一个电话号码表示为字符串,则其长度在 11 到 1010 之间。电话号码可以包含前导零。

输出格式

Print out the ordered information about the phone numbers of Vasya's friends. First output m — number of friends that are found in Vasya's phone books.

The following m lines must contain entries in the following format "name number_of_phone_numbers phone_numbers". Phone numbers should be separated by a space. Each record must contain all the phone numbers of current friend.

Entries can be displayed in arbitrary order, phone numbers for one record can also be printed in arbitrary order.

输出瓦西亚朋友们的电话号码的有序信息。首先输出 m —— 瓦西亚电话簿中找到的朋友人数。

接下来的 m 行必须包含如下格式的条目:“name number_of_phone_numbers phone_numbers”。电话号码之间用空格分隔。每条记录必须包含当前朋友的所有电话号码。

条目可以以任意顺序输出,同一条记录中的电话号码也可以以任意顺序输出。

输入输出样例

  • 输入#1

    2
    ivan 1 00123
    masha 1 00123

    输出#1

    2
    masha 1 00123 
    ivan 1 00123
  • 输入#2

    3
    karl 2 612 12
    petr 1 12
    katya 1 612

    输出#2

    3
    katya 1 612 
    petr 1 12 
    karl 1 612
  • 输入#3

    4
    ivan 3 123 123 456
    ivan 2 456 456
    ivan 8 789 3 23 6 56 9 89 2
    dasha 2 23 789

    输出#3

    2
    dasha 2 23 789 
    ivan 4 789 123 2 456

输入解题思路,AI测评打分。不知道怎么写?

首页