Problem A
Golomb Rulers
A ‘Golomb ruler’ is a set of unique positive integers
(called ‘marks’) which can be used to measure distances by
using the difference between pairs of marks. Golomb rulers are
useful in designing radio antennae and in cryptography. It’s
helpful to think of the marks as being measurement marks on a
real ruler. For example,
which are visually demonstrated as the arrows above the ruler in Figure 1.
![\includegraphics[width=0.4\textwidth ]{golomb-figure0}](/problems/golombrulers/file/statement/en/img-0001.png)
If a Golomb ruler can be used to measure all distances from
For this problem, you need to determine whether some set of numbers make a Golomb ruler, and if that Golomb ruler is perfect.
Input
Each line of input contains a list of at least two but at
most
Output
For each input line, if the numbers given make a perfect
Golomb ruler, output ‘perfect’. If they
make a Golomb ruler that is not perfect, output ‘missing’ followed by a space-separated list of
numbers that are missing from the ruler in the range
Sample Input 1 | Sample Output 1 |
---|---|
0 1 2 0 3 1 0 5 0 1 4 9 10 0 1 4 9 11 |
not a ruler perfect missing 1 2 3 4 not a ruler missing 6 |