Gerard the handyman P41570


Statement
 

pdf   zip

thehtml

Gerard the handyman is a resourceful fellow. He loves to tinker with and repair his bike. Unfortunately, he has lost one of his precious tools: his ruler.

To compensate, he takes a bar of length 6 cm and marks two points on it, at 1 cm and 4 ‍cm. With these marks, he can now measure any integer length from 1 to 6. Moreover, each measurement can be made in exactly one way:

[thick] (0,0) – (6,0);

(0,0.2) – (0,-0.2) node[below] 0; (6,0.2) – (6,-0.2) node[below] 6;

(1,0.2) – (1,-0.2) node[below] 1; (4,0.2) – (4,-0.2) node[below] 4;

[<->] (0,-0.8) – (1,-0.8) node[midway,below] 1; [<->] (4,-0.8) – (6,-0.8) node[midway,below] 2;

[<->] (1,-1.6) – (4,-1.6) node[midway,below] 3; [<->] (0,-2.4) – (4,-2.4) node[midway,below] 4; [<->] (1,-3.2) – (6,-3.2) node[midway,below] 5; [<->] (0,-4.0) – (6,-4.0) node[midway,below] 6;

Given a bar of length n and k marked points given in increasing order, please determine whether it is possible to measure all lengths from 1 to n. Additionally, determine whether each measurable length can be obtained in a unique way or in multiple ways.

Input

Input consists of several cases, each one with n and k, followed by the positions pi of the points. Assume 2 ≤ n ≤ 1000, 1 ≤ k < n, and 1 ≤ p1 < p2 < … < pk < n.

Output

For every case, print “YES” or “NO” followed by “unique” or “multiple”, depending on the answer.

Public test cases
  • Input

    6 2  1 4
    72 9  1 4 13 28 33 47 54 64 70
    72 10  1 4 9 19 24 31 52 56 58 69
    10 4  1 2 3 6
    

    Output

    YES unique
    NO unique
    NO multiple
    YES multiple
    
  • Information
    Author
    Joan Alemany
    Language
    English
    Official solutions
    C++
    User solutions
    C++