Rooks inside a rectangle P31389


Statement
 

pdf   zip

Consider a rectangular board r×cr \times c with rcr \le c. Write a program that prints all the ways to place rr rooks on the board so that no rook threatens another rook.

Input

Input consists of two natural numbers rr and cc, with 1rc1 \le r \le c.

Output

Print all the ways to place rr 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.

Public test cases
  • Input

    2 3
    

    Output

    R..
    .R.
    
    R..
    ..R
    
    .R.
    R..
    
    .R.
    ..R
    
    ..R
    R..
    
    ..R
    .R.
    
    
  • Input

    1 1
    

    Output

    R
    
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python