HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50835 - Club Presidency

Guest
• Review clarifications (1)

Volume problems

• 50457 - The Number of Winners
• 50752 - Student Groups
• 50451 - Processing Cost
• 50751 - The biggest Minute
• 50468 - Draw Matrix - 2
• 50470 - Close Pairs - Revised
• 50998 - CEN112 Homework, quiz av...
• 50804 - Marathon
• 50835 - Club Presidency
• 50526 - Gold Market
• 50458 - Weekly Report
• 50872 - Top M Grades
• 50868 - Sort Frequencies
• 50405 - Accounts Receivable
• 50371 - Modified Karnaugh-Map
• 50908 - Buy 1 Get 1
• 50906 - The Smallest Pair

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.

Club Presidency

Club presidency election is going on at the university. As the club members, you have decided for the following rules:

  • Everybody can vote for two candidates.
  • If one of the votes for a non existing candidate, only that part of the vote is invalid.
  • If somebody votes twice for the same person, all the vote is invalid.
    • If a candidate is in the first position, (s)he takes 2 points
    • if a candidate is in the second position, (s)he gets 1 point.

Question: Write a program that is going to calculate the votes received and show the IDs of top m candidates.

Input specification
In the first line, you will be given three integers:

  1. The number of people voting (n) where n is between 1 and 60,000
  2. The number of candidates (k) where k is between 1 and 60,000
  3. The number of top (m) candidates to show in the end where m is between 1 and 10,000
where candidates have the IDs from 1 to k. Then, in the following n lines, you will be given 2 integers (IDs of the candidates voted).

Output specification
Show IDs of top m candidates. If there are two candidates with the same points, first show the one whose ID is smaller.

Sample Input
5 4 2
5 2
3 2
2 4
2 2
3 3
Sample Output
2 3

Explanation: There are 4 candidates and 5 students voted.

  1. The first student voted for candidate 5 (which is invalid) and the second candidate (1 points).
  2. The second student gave two points to the third candidate and 1 point to the second candidate
  3. The third student gave two points to the second candidate and 1 point to the fourth candidate
  4. The fourth and fifth students voted for the same person twice, so, the votes are invalid.
Then, the second candidate has 4 points, the third candidate has 2 points, and the fourth candidate has 1 point.



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

www.contester.ru