| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12102 | Dynamic 2D array |
|
| 12523 | Inventory |
|
Description
In this problem, you are asked to design two functions
1.
unsigned** new_2d_array(unsigned n,unsigned m);
malloc an n*m 2D unsigned array, and then return its address. The main function will check the correctness of your array.
2.
void delete_2d_array(unsigned **arr);
Free the memory space of your array that was previously allocated by using malloc. Be careful about the memory uage of your program allocated dynamically so as to avoid MLE.
The two functions have been declared in function.h, and you are asked to complete the function definitions in function.c.
Your program should construct the 2D array by using only two malloc function calls. Notice that malloc is a time-consuming operation.
Note: for OJ submission:
Step 1. Submit only your function.c into the submission block. (Please choose C compiler)
Step 2. Check the results and debug your program if necessary.
Input
Please refer to the main function.
The input only has one line, consisting of four positive integers t,n,m,r separated by space characters, where t is the number of tests, (n,m) represents the array size, and r is a parameter for testing.
Note that n*m<=100000000 and t*n*m<=100000000
Output
In order to test your array's correctness, we will use your array to do some computations and output the results.
Sample Input Download
Sample Output Download
Partial Judge Code
12102.cPartial Judge Header
12102.hTags
Discuss
Description

You are going to implement a Pokemon Go Inventory Display System. Given the name, current hp, and max hp of pokemons, you are going to sort them in the following order.
-
The pokemon whose hp is not full (i.e. current hp < max hp) goes to the front
-
The pokemon whose current hp is less goes to the front
-
The pokemon whose max hp is less goes to the front
Please print the names, current hp, and max hp of the pokemons after you finish sorting. Refer to IO for format.
Input
The input is given in the following format :
n name_1 c_1 m_1 ... name_n c_n m_n
The first line contains an integer n (1 <= n <= 100). The next n lines are the names, current hp and max hp for each pokemon.
It is guaranteed that :
-
there will be no two pokemons with both same current hp and same max hp
-
1 <= length of pokemon name <= 20, pokemon name contains English Alphabets only.
-
0 <= current hp <= max hp <= 1000 for each pokemon
Output
Please print the names, current hp, and max hp of the pokemons after you finish sorting. Each line contains the pokemon's name, current hp, max hp, separated by space. There is no trailing space after max hp. Please add a new line character in the end of each line.