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

Разделы > Non-linear Data structures: Map, Set, Priority Queues > задача:


51023 - Preparing Keyword Index

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

Задачи раздела

• 50789 - Number of Cities
• 50983 - Course Selection
• 51024 - Total Stock Price
• 50987 - Very Looong Queue
• 50993 - Products in store
• 50869 - Birthday Celebration
• 50981 - Top popular m-students
• 50794 - Writing Files Into HDD
• 51023 - Preparing Keyword Index
• 50706 - The most crowded Club
• 50793 - Top M Customers
• 50569 - Lendet me zgjedhje per kla...
• s
• 50795 - Trunk

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

Если у вас есть предложения или пожелания по работе 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