欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1499A.Domino on Windowsill
Domino on Windowsill
You have a board represented as a grid with cells.
The first cells on the first row and first cells on the second row are colored in white. All other cells are colored in black.
You have white dominoes ( tiles, both cells are colored in white) and black dominoes ( tiles, both cells are colored in black).
You can place a white domino on the board if both board's cells are white and not occupied by any other domino. In the same way, you can place a black domino if both cells are black and not occupied by any other domino.
Can you place all dominoes on the board if you can place dominoes both horizontally and vertically?
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains three integers , and (; ).
The second line of each test case contains two integers and ().
Output
For each test case, print YES if it's possible to place all dominoes on the board and NO, otherwise.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).
Note
In the first test case, , and . It means that board has black cell and white cell . So, you can't place any white domino, since there is only one white cell.
In the second test case, the board of the same size , but both cell are white. Since and , so you can place dominoes on the board.
In the third test case, board , but fully colored in black (since ), so you can't place any white domino.
In the fourth test case, cells , , , and are white and other cells are black. You can place white dominoes at positions and and black dominoes at positions .
Samples
5
1 0 1
1 0
1 1 1
0 0
3 0 0
1 3
4 3 1
2 2
5 4 3
3 1
NO
YES
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |