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

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


51023 - Preparing Keyword Index

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

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

• 51086 - Top popular student
• 51015 - Student Scholarships
• 50828 - Arranging Time Table
• 50447 - Swimming Contest - 2
• 51072 - Castle on chessboard
• 51082 - Sum is equal to K - 1
• 50794 - Writing Files Into HDD
• 51020 - Number of nodes removed
• 51023 - Preparing Keyword Index
• 50929 - Present from your uncles
• 51075 - Shortest Path for Bishop
• 50863 - Total Access Cost of a BST
• 50979 - Minimum access cost for BST
• 50688 - Epoka Furgon
• 50750 - Service Time - 2
• 50706 - The most crowded Club
• 50689 - The biggest building block

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

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

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

Preparing Keyword 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 print the index pages for a given word.

Input specification: In the first line, you will be given two integers: the number of pages (n) with keywords, and the max number of index pages to keep (max). 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. After that, you will be given a keyword. Where 1 ≤ n ≤ 40,000, 1 ≤ max ≤ 100 and there may at most 50 keywords in one page.

Output specification: Show the pages that the given keyword appears in ascending order. Show 0, if it doesn't appear on any page. Note: Keep at most max unique-index pages for every keyword. The max index pages will be decided according to the order of appearance. The index page appearing on the after max pages or later will be ignored.

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

Explanation: There are four pages with keywords and maximum (the first) 2 index pages will be shown. Page 1 contains 2 keywords: book and index, and, there are 5 keywords in total. The following is the list of keywords and their appearing pages:

  • appear 7
  • book 1
  • index 1 5 7
  • keyword 4 5
  • search 5 7
Although, index word appears on three pages: 1, 5 and 7, the program should show only the first two pages 1 7 according to order of appearance, because Max pages given as 2.



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

www.contester.ru