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

Турниры > CEN303_2016Questions > задача:


PE11. 51023 - Preparing Keyword Index

CEN303_2016Questions

Старт: 28.окт.2016 в 17:00:00
Финиш: 01.ноя.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

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

Задачи турнира

• HW081. 51044 - Number of Trees
• HW082. 50699 - Fighting Vampires
• HW083. 50671 - Phalanx
• HW091. 51061 - The Longest Path
• HW101. 50682 - Hotel Durres
• HW102. 51067 - Jumping frog
• HW111. 50506 - The Biggest Island
• HW112. 50698 - Ayran Delivery
• PE11. 51023 - Preparing Keywo...
• PE12. 50835 - Club Presidency
• PE13. 51024 - Total Stock Price
• PE14. 50998 - CEN112 Homework, ...
• PE21. 51071 - Phalanx-2
• PE22. 51072 - Castle on chessboard
• RE1. 51079 - Key person - 2
• RE2. 51080 - Deepest Point

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

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