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

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


50981 - Top popular m-students

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

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

• 50985 - Books Waiting
• 50995 - Group Average
• 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 - Lendet me zgjedhje per kla...
• s

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

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

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

Top popular m-students

Question: For a contest, you are searching for the top-m popular students of the university. You are given friends list of n students where some students may appear several times. Count the unique number of friends for each student and identify the top m popular students who have the most number of friends.

Input specification You will be given two integers in the beginning: the number of students (n) and top m students to list. In each of the following n lines, you will be given several positive integers (friends of the current student) ending with a negative number where 0 ≤ m ≤ n ≤ 8,000.

Output specification: Show the IDs (order of appearance) of top m students who have the most number of friends. If there are several students with the same number friends, first show the student with a smaller ID.

Sample Input
7 3
5 5 7 7 1 -1
6 4 2 5 6 -1
6 6 7 4 5 4 -1
2 7 1 1 7 7 6 5 -1
3 6 4 7 -1
7 6 6 1 7 -1
3 4 5 2 5 1 1 -1
Sample Output
4 7 2

Explanation: Here is the list of students with their number of friends.
  1 -> 3
  2 -> 4
  3 -> 4
  4 -> 5
  5 -> 4
  6 -> 3
  7 -> 5



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

www.contester.ru