Yazmonkey is the King of the banana milk kingdom. He got everything he wants except a wife. So he host a wife-chosen ceremony, he wants to choose the richest monkey among all candidates, which means he will choose the monkey who possesses the most banana milk.
You're asked to help Yazmonkey to complete the code in order to successfully select the best choice. What you have to implement is as follow.
typedef struct { int num; char* name; } Monkey;
First you have a structure of monkey, num represents the amount of banana milk it possess.
Monkey* CreateMonkeyArray(int);
You should return a pointer points to the Monkey array with length equal to the parameter.
void SetVal(Monkey*, int, int, char[]);
Set the value of the index of second parameter of the Monkey array as the last two parameter.
Be caution that main.c has already malloc the char array to store the input string.
int Compare(Monkey*, int, int);
Return 1 if the index of third parameter of the Monkey array have a higher priority than the index of second parameter of the Monkey array.
void Swap(Monkey*, int, int);
Swap the value in the Monkey array.
void FreeMonkeyArray(Monkey*, int);
Free the Monkey array with length equal to the parameter.
If you think the above description is not clear, you should trace the sorce code for detailed.
First line of the input contains one integer T, (T <= 10) indicates the number of testcases.
For each testcase, first input an integer N, (N <= 50), representing the number of candidates.
Next, Input contains N lines. In i-th line, it contains one integer Ki, (1 <= Ki <= 50) and one string S, (|S| <= 100000) which reprecenting the number of cartons of banana milks the i-th candidate has and the name of the monkey.
Guarentee that there's no two monkey has the same name.
Output the order of the candidates sorted by the number of banana milk in decending order. If two candidates have the same amount of the banana milk, them sort it by the contray of lexicographic order.