Skip to content

mfcecilia/sets-maps-queues

Repository files navigation

sets-maps-queues

VT Programming team lecture 2016.02.02

Unique Usernames
Time Limit: 2 seconds

After the great job you did with verifying the ages of the users last week for the Intergalactic Social Network, you have now been assigned with fixing more problems with how the registration process works. Users have been trying to register the same usernames multiple times, and obviously we can not allow this to happen! You will be provided with a set of registrations, it is your job to output whenever a username that perviously has been taken is used again

Input
Each input will consist of a single test case. The first line of input will contain a single integer N (1≤N≤100001≤N≤10000) denoating the number of usernames that will be in the input. This will be followed by a list of N usernames, one per line. A username will consist of one word, and will consist of only lowercase alphanumeric characters.

Output
Each time a username is encountered that has already been taken output “Invalid Username:” followed by the username. After all the usernames have been encountered output the usernames that were valid in alphabetical order, one per line.

Sample Input 1 8
askywalker
o1kenobi
vader
darkside
o1kenobi
usetheforce
vader
dvader

Sample Output 1
Invalid Username: o1kenobi
Invalid Username: vader
askywalker
darkside
dvader
o1kenobi
usetheforce
vader

Intergalactic Elections
Time Limit: 2 seconds

It is time for the yearly intergalactic elections to take place! This year the senate has met and decided that since everyone is using the Intergalactic Social Network that it would make sense to have to voting take place through the network. You have been tasked to count the votes after the election has taken place.

Input
Each input will consist of a single test case. The first line of input will contain a single integer N (1≤N≤100001≤N≤10000) denoating the number of votes that will be in the input. This will be followed by a list of N votes, one per line. A vote will consist of one word, the username of the person who is being voted for. As before a username will consist of only lowercase alphanumeric characters.

Output
Output the username which recieved the most number of votes, if there is a tie for who recieved the most votes output “Tie detected!”

Sample Input 1 8
yoda
o1kenobi
yoda
o1kenobi
vader
yoda
vader
yoda

Sample Output 1
yoda

Sample Input 2 8
yoda
o1kenobi
yoda
o1kenobi
vader
yoda
vader
o1kenobi

Sample Output 2
Tie detected!