ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Data Structures > задача:


51000 - Book Index

Гость
• Вопросы к жюри (1)

Задачи сборника

• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD
• 50929 - Present from your uncles
• 50863 - Total Access Cost of a BST
• 50979 - Minimum access cost for BST
• 51000 - Book Index
• 51076 - Key person
• 51062 - Fish Pond II
• 51067 - Jumping frog
• 51080 - Deepest Point
• 51079 - Key person - 2
• 51021 - Number of Nodes
• 51044 - Number of Trees
• 51010 - Max Sequential Sum

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Book Index

Question: The books have indexes at the end, so that, people can search for a specific topic or section using a keyword. You are given the index pages with keywords. Then, you are asked to prepare the index of the book. Write a program which reads the page and keyword information. Then, the program should prepare the index for the book.

Input specification: In the first line, you will be given an integer: the number of pages (n) with keywords. The following n lines start with two integers the page number (p) and the number of keywords (k) in that page where keywords are all in lowercase and contain only 26 English letters with no special char. Then, you will be given k keywords in the same line. where 1 ≤ n ≤ 10,000 and there may at most 100 keywords in one page.

Output specification: Show each keyword in a line. Keywords will be in alphabetical order followed by the page numbers (in ascending order) that they appear.

Sample Input
4
1 2 book index
4 1 keyword
5 3 index keyword search
7 3 index search appear

Sample Output
appear 7
book 1
index 1 5 7
keyword 4 5
search 5 7

Explanation: There are four pages with keywords given. The first page contains 2 keywords: book and index. There are 5 keywords in total and the keyword "book" appears only in page 1.



Для отправки решений необходимо выполнить вход.

www.contester.ru