Sebastian's toy-friends P74548


Statement
 

pdf   zip

html

J. F. Sebastian is a genetic designer working for Tyrell Corporation. In his spare time, he makes small humanoid robots that are his toy-friends. Sebastian currently has n heads, n bodies and n pairs of legs, and he wonders how these parts can be distributed to construct n toy-friends.

Heads are codified with uppercase letters (starting at A), bodies with digits (starting at 0), and legs with lowercase letters (starting at a). This way, a toy-friend can be codified with three characters, and any distribution of the 3n pieces can be described with n triples of characters. For instance, a possible distribution for n = 2 is A1b–B0a: one robot (A1b) consists of the first head, the second body and the second pair of legs, while the other robot (B0a) consists of the second head, the first body and the first pair of legs. The other possible distributions are A0a–B1b, A0b–B1a and A1a–B0b.

[r]

Input

Input consists of several cases, each with a positive integer n. A special case with n = 0 ends the input.

10

Output

For every case, print its number starting at one, followed by all the possible distributions in increasing order. The codifications of the toy-friends inside each distribution must also appear in increasing order, separated with dashes.

Public test cases
  • Input

    2
    1
    2
    0
    

    Output

    Case 1
    A0a-B1b
    A0b-B1a
    A1a-B0b
    A1b-B0a
    Case 2
    A0a
    Case 3
    A0a-B1b
    A0b-B1a
    A1a-B0b
    A1b-B0a
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++
    Event
    Sisè Concurs de Programació de la UPC - Semifinal
    Date
    2008-06-28