Rooks inside a rectangle

Consider a rectangular board r × c with r ≤ c. Write a program that
prints all the ways to place r rooks on the board so that no rook
threatens another rook.

Input

Input consists of two natural numbers r and c, with 1 ≤ r ≤ c.

Output

Print all the ways to place r rooks on the board so that no rook
threatens another rook. Represent the rooks with a ‘R’, and the empty
positions with a dot. Print an empty line after each board.

Information about the checker

You can print the solutions to this exercise in any order.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T10:12:10.043Z

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