Pacific rooks

Your task is to write a program that prints all the ways of placing n
rooks in a chessboard n × n, in order to no rook threatens other one

Input

The input is a sequence of at most 20 naturals, each one between 1 and
7. The sequence ends in 0.

Output

For each number n of the input, your program must print all the ways to
place n rooks in a board n × n, in order to no rook threatens other one.
Remember that rooks move (and threaten) horizontally and vertically.

The different solutions must appear in lexicographical order. It is,
between two solutions, appears first the one that has the first row rook
more on the left. In a event of a tie, the second row is seen. If the
tie persists, the third row is seen, etc.

The output has to follow the same format than the instance. The rooks
are indicated by a R, the empty positions with a dot. Your program must
print a line in white after each solution, and a line with 10 dashes
after all the solutions for a n given.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:13:24.901Z

© Jutge.org, 2006–2026.
https://jutge.org
