Golden Tickets
InterviewTime limit1sMemory limit2048 MB
Given ranked teams and their institutions, pick the top M teams plus up to K more teams from new institutions, then print them in rank order.
- Level
Easy3 of 10
- Topics
- Hash map, Simulation
- Solved
- No attempts yet
Problem
There are teams participating in INC 2023. The team ranked th is team , representing institution . The top teams in INC 2023 are eligible to participate in The ICPC Asia Jakarta 2023.
Apart from the top teams, Golden Tickets are given to at most the top teams whose institutions are not in the top of INC 2023. Each institution receives at most one Golden Ticket, and only the highest-ranked team from each institution qualifies. Teams that receive a Golden Ticket can participate in The ICPC Asia Jakarta 2023.
Determine the number of teams that receive Golden Tickets. Then output the names of those teams, sorted by rank.
Input
The first line contains three integers , , ().
Each of the next lines contains two strings and separated by a space (). All strings consist of uppercase letters. No two teams have the same name, so for .
Output
On the first line, print the number of teams that receive Golden Tickets. Then print lines, each containing the name of one such team, sorted by rank. If , print no names.
Hint
Disclaimer
All team names and institution names in the samples are fictional. Any similarities with actual participants in INC 2023 are purely coincidental.