欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1621A.Stable Arrangement of Rooks
Stable Arrangement of Rooks
You have an chessboard and rooks. Rows of this chessboard are numbered by integers from to from top to bottom and columns of this chessboard are numbered by integers from to from left to right. The cell is the cell on the intersection of row and collumn for and .
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 rooks on the chessboard is good, but it is not stable: the rook from can be moved to the adjacent cell and rooks on cells and will beat each other.
Please, find any stable arrangement of rooks on the chessboard or report that there is no such arrangement.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers , () — the size of the chessboard and the number of rooks.
Output
If there is a stable arrangement of rooks on the chessboard, output lines of symbols . and R. The -th symbol of the -th line should be equals R if and only if there is a rook on the cell in your arrangement.
If there are multiple solutions, you may output any of them.
If there is no stable arrangement, output .
Note
In the first test case, you should find stable arrangement of rooks on the chessboard. Placing them in cells and gives stable arrangement.
In the second test case it can be shown that it is impossbile to place rooks on the chessboard to get stable arrangement.
Samples
5
3 2
3 3
1 1
5 2
40 33
..R
...
R..
-1
R
.....
R....
.....
....R
.....
-1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |