Lucy and the Number Game
All submissions for this problem are available.
Read problems statements in Russian here
Lucy had recently learned the game, called Natural Numbers.
The rules of the game are really simple. There are N players. At the same time, every player says one natural number. Let's call the number said by the i-th player Ai. The person with the smallest unique number (that is, the smallest number that was not said by anybody else) wins. Sometimes, there is a case when there are no unique numbers at all. Then the game is obviously a draw, so nobody wins it.
Sometimes, it's hard to determine the winner, especially, when the number of players is enormous. So in this problem, your assignment will be: given the names of the players and the numbers every of them have said. Please, tell the name of the winner, or determine that nobody wins.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of every test case consists of a single integer N - the number of players. Then, N lines will follow. Each of these N lines will consist of the player's name and the number Ai said by her, separated by a single space.
For each test case, output a single line containing an answer to the corresponding test case - the name of the winner, or a string "Nobody wins.", if nobody wins the game.
Input: 2 5 Kouta 1 Yuka 1 Mayu 3 Lucy 2 Nana 5 2 Lucy 2 Nana 2 Output: Lucy Nobody wins.
Subtask 1 (17 points): T = 10000, 1 <= N <= 10, 1 <= Ai <= 10
Subtask 2 (19 points): T = 10000, 1 <= N <= 10, 1 <= Ai <= 2*109
Subtask 3 (30 points): T = 100, 1 <= N <= 1000, 1<= Ai <= 2*109
Subtask 4 (34 points): T = 10, 1 <= N <= 10000, 1 <= Ai <= 2*109
You can safely assume that in all the test cases the length of any name will not exceed five letters. All the players' names are unique.
|Tags||cakewalk, ltime06, sorting, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.