CF1621A.Stable Arrangement of Rooks

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have an n×nn \times n chessboard and kk rooks. Rows of this chessboard are numbered by integers from 11 to nn from top to bottom and columns of this chessboard are numbered by integers from 11 to nn from left to right. The cell (x,y)(x, y) is the cell on the intersection of row xx and collumn yy for 1xn1 \leq x \leq n and 1yn1 \leq y \leq n .

The arrangement of rooks on this board is called good, if no rook is beaten by another rook.

A rook beats all the rooks that shares the same row or collumn with it.

The good arrangement of rooks on this board is called not stable, if it is possible to move one rook to the adjacent cell so arrangement becomes not good. Otherwise, the good arrangement is stable. Here, adjacent cells are the cells that share a side.

Such arrangement of 33 rooks on the 4×44 \times 4 chessboard is good, but it is not stable: the rook from (1,1)(1, 1) can be moved to the adjacent cell (2,1)(2, 1) and rooks on cells (2,1)(2, 1) and (2,4)(2, 4) will beat each other.Please, find any stable arrangement of kk rooks on the n×nn \times n chessboard or report that there is no such arrangement.

输入格式

The first line contains a single integer tt ( 1t1001 \leq t \leq 100 ) — the number of test cases.

The first line of each test case contains two integers nn , kk ( 1kn401 \leq k \leq n \leq 40 ) — the size of the chessboard and the number of rooks.

输出格式

If there is a stable arrangement of kk rooks on the n×nn \times n chessboard, output nn lines of symbols . and R. The jj -th symbol of the ii -th line should be equals R if and only if there is a rook on the cell (i,j)(i, j) in your arrangement.

If there are multiple solutions, you may output any of them.

If there is no stable arrangement, output 1-1 .

输入输出样例

  • 输入#1

    5
    3 2
    3 3
    1 1
    5 2
    40 33

    输出#1

    ..R
    ...
    R..
    -1
    R
    .....
    R....
    .....
    ....R
    .....
    -1

说明/提示

In the first test case, you should find stable arrangement of 22 rooks on the 3×33 \times 3 chessboard. Placing them in cells (3,1)(3, 1) and (1,3)(1, 3) gives stable arrangement.

In the second test case it can be shown that it is impossbile to place 33 rooks on the 3×33 \times 3 chessboard to get stable arrangement.

首页