11937 - QuickSort for Molecules   

Description

Sampe input/out 就是測資1。測資 2~8 有給定分子量。

Group 的大小最大約 1800 (i.e., 排序 1800 個分子)。

Objective

  1. Given several groups of molecules
    • There may be duplicated molecules
  2. 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
  3. Quicksort each group of molecules according to the ascending order of molecular mass
  4. 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

Sample Input  Download

Sample Output  Download

Tags




Discuss