HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array_and_Matrices > problem:


50206 - Club Presidency

Volume problems

• 50185 - Word Puzzle
• 50188 - Swimming Contest
• 50189 - Top Question
• 50190 - Eight Puzzle
• 50191 - Number of Cities
• 50195 - Comparing Exams
• 50196 - Marathon
• 50205 - Secret Number
• 50206 - Club Presidency
• 50207 - Parking Place
• 50208 - Area of Triangle Revised
• 50209 - Number of Student Certificates
• 50210 - The largest Student Group
• 50212 - Buy the cheapest
• 50214 - Birthday Celebration
• 50215 - ZScore normalization
• 50216 - Top M Grades

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