Problema de Março de 2005: Stem-and-Leaf Plots

Este foi o problema A da 1ª edição da TIUP2005, em Aveiro. Resolvi-o em pouco mais de 6 minutos :) É muito fácil de tiverem conhecimento da STL (C++), nomeadamente do std::set e do std::map. Se quiserem testar a vossa solução, podem fazê-lo durante algum tempo em mooshak.pisharp.org.

Problem

The program should draw a stem-and-leaf plot for a sample containing positive integer numbers. The definition of this kind of plot is the following:

Input

The input is a column of integers.
  1. The first integer is the length of the sample.
  2. Other integers are sample elements not necessarily sorted.
  3. One assumes the input to be lower than 1000.

Output

The stem-and-leaf plot is the output.
  1. Each line contains a different stem number which groups all leaves with equal stem in front of it.
  2. Stems are sorted, line by line.
  3. Leaves, in front of each stem, are also sorted.
  4. The separation of stems and leaves is made by a dot `.'.
  5. This dot, in each line, must occupy the 3th column.
  6. Space char must fill empty space until stem. Please, see spaces in Sample Output.

Sample Input

7
4
4
5
10
12
137
999

Sample Output

 0.445
 1.02
13.7
99.9