欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1680B.Robots
Robots
There is a field divided into rows and columns. Some cells are empty (denoted as E), other cells contain robots (denoted as R).
You can send a command to all robots at the same time. The command can be of one of the four types:
- move up;
- move right;
- move down;
- move left.
When you send a command, all robots at the same time attempt to take one step in the direction you picked. If a robot tries to move outside the field, it explodes; otherwise, every robot moves to an adjacent cell in the chosen direction.
You can send as many commands as you want (possibly, zero), in any order. Your goal is to make at least one robot reach the upper left corner of the field. Can you do this without forcing any of the robots to explode?
Input
The first line contains one integer () — the number of test cases.
Each test case starts with a line containing two integers and () — the number of rows and the number of columns, respectively. Then lines follow; each of them contains a string of characters. Each character is either E (empty cell} or R (robot).
Additional constraint on the input: in each test case, there is at least one robot on the field.
Output
If it is possible to make at least one robot reach the upper left corner of the field so that no robot explodes, print YES. Otherwise, print NO.
Note
Explanations for test cases of the example:
- in the first test case, it is enough to send a command to move left.
- in the second test case, if you try to send any command, at least one robot explodes.
- in the third test case, it is enough to send a command to move left.
- in the fourth test case, there is already a robot in the upper left corner.
- in the fifth test case, the sequence "move up, move left, move up" leads one robot to the upper left corner;
- in the sixth test case, if you try to move any robot to the upper left corner, at least one other robot explodes.
Samples
6
1 3
ERR
2 2
ER
RE
2 2
ER
ER
1 1
R
4 3
EEE
EEE
ERR
EER
3 3
EEE
EER
REE
YES
NO
YES
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |