11937 - QuickSort for Molecules
|
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
Sampe input/out 就是測資1。測資 2~8 有給定分子量。
Group 的大小最大約 1800 (i.e., 排序 1800 個分子)。
Objective
- 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
- A non-zero value means the mass is given
- Quicksort each group of molecules according to the ascending order of molecular mass
- Print out the molecules and also report the number of swaps used during Quicksort
- Quicksort
- Always pick the first entry of each partition as the pivot

- Do not count swap(array, posi, posj) if posi == posj
- Online molecular mass calculator (reference only)
Input

Output

Tags