HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


51000 - Book Index

Guest
• Review clarifications (1)

Volume problems

• 50708 - Binary Strings
• 50694 - The Cheapest Flight
• 50996 - Checkers - the shortest path
• 50770 - Average Depth
• 50796 - KNN
• 50291 - Postfix Arithmetic Expressions
• 50340 - Game 19
• 50836 - Censored
• 51000 - Book Index
• 50505 - kht Puzzle
• 51076 - Key person
• 51062 - Fish Pond II
• 51067 - Jumping frog
• 50840 - Tanker trucks
• 51080 - Deepest Point
• 51079 - Key person - 2
• 50877 - Friendly Queue

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