11943 - QuickSort for Molecules (CS2351)
|
Time |
Memory |
Case 1 |
1 sec |
32 MB |
Case 2 |
1 sec |
32 MB |
Case 3 |
1 sec |
32 MB |
Case 4 |
1 sec |
32 MB |
Case 5 |
1 sec |
32 MB |
Case 6 |
1 sec |
32 MB |
Case 7 |
1 sec |
32 MB |
Case 8 |
1 sec |
32 MB |
Case 9 |
1 sec |
32 MB |
Case 10 |
1 sec |
32 MB |
Description
- Given several groups of molecules
- There may be duplicated molecules
- Each molecule has
- A name string (e.g., "caffeine")
- A formula string (e.g., "C8H10N4O2")
- Molecular mass (can be zero or non-zero)
- A zero means that your program needs to calculate the mass (Use this periodic table and double is recommended while calculating the mass )
- A non-zero value means the mass is given
- Quicksort each group of molecules according to the ascending order of molecular mass
- Always pick the first entry of each partition as the pivot
- Do not count swap(array, posi, posj) if posi == posj
- Print out the molecules and also report the number of swaps used during Quicksort
- Processing steps example:

Input
- Note:
- The input 1 is the same as sample input/out.
- All of the molecular masses in input 2~8 are given. (In other words, only input 9 and 10 need to calculate the masses by your own)

Output

Tags