HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50835 - Club Presidency

Guest
• Review clarifications (1)

Section problems

• 50756 - Average of the Nth Student
• 50757 - National Elections - 1
• 50755- Top N Donors - 1
• 50752 - Student Groups
• 50753 - Average of the Nth Student
• 50751 - The biggest Minute
• 50998 - CEN112 Homework, quiz av...
• 50804 - Marathon
• 50835 - Club Presidency
• 50747 - Safe boxes against thieves
• 50742 - King Arthur II
• 50352 - Selling Cows
• 50872 - Top M Grades
• 50868 - Sort Frequencies
• 50912 - Trip to Librazhd
• Trip to Librazhd
• 50361 - Align Two Lists

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