HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Non-linear Data structures: Map, Set, Priority Queues > problem:


51000 - Book Index

Guest
• Review clarifications (1)

Section problems

• 50983 - Course Selection
• 50517 - Confusion Matrix
• 50789 - Number of Cities
• 50993 - Products in store
• 50987 - Very Looong Queue
• 50869 - Birthday Celebration
• 50981 - Top popular m-students
• 50794 - Writing Files Into HDD
• 51000 - Book Index
• 51024 - Total Stock Price
• 51023 - Preparing Keyword Index
• 50706 - The most crowded Club
• 50793 - Top M Customers
• 50569 - 12th Grade Elective Subjects
• Problem 3

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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